Control QLC+ with Stream Deck

Ask a generic question about the usage of QLC+, not related to a particular operating system
Post Reply
waxcam
Posts: 4
Joined: Wed Dec 06, 2023 3:33 pm
Real Name: Joe Long

[youtube] https://www.youtube.com/watch?v=J4ZLBu0XFmc/[/youtube]

Really basic Stream Deck control of QLC+ to swap scenes etc

I am working on controlling lights in unreal engine 5 for virtual production , This is the first part of that process, you can use it for controlling sequences etc I hope it helps someone.



import asyncio
from StreamDeck.DeviceManager import DeviceManager
from websocket import create_connection, WebSocketException
# Target WebSocket server URL (to send a message upon button press)
TARGET_WS_URL = "ws://127.0.0.1:9999/qlcplusWS" # Change this to your Qlc+ URL
ws = create_connection(TARGET_WS_URL)

# Function to send a message over WebSocket with error handling
def send_message(TARGET_WS_URL,key):
try:
#ws = create_connection(TARGET_WS_URL)
ws.send(f"{key}|255")

print(f"{key}|255")
except WebSocketException as e:
print(f"WebSocket Handshake: {e}")
except Exception as e:
print(f"Unexpected error: {e}")

# Callback function for button presses with improved error handling
def key_change_callback(deck, key, state):
try:
if state: # Button is pressed
print(f"Button {key} pressed")
# Now also send a message to the target WebSocket server
send_message(TARGET_WS_URL,key) #need to format the message to give the button number here
else: # Button is released
print(f"Button {key} released")
except Exception as e:
print(f"Error handling button {key} press/release: {e}")

# Main function remains the same
def main():
stream_decks = DeviceManager().enumerate()
if not stream_decks:
print("No Stream Deck found.")
return

deck = stream_decks[0]
print("Found Stream Deck")

deck.open()
deck.reset()
deck.set_key_callback(key_change_callback)

print("Press buttons on your Stream Deck. Press Ctrl+C to quit.")

try:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_forever()
except KeyboardInterrupt:

print("Exiting...")
finally:
deck.close()
ws.close()

if __name__ == "__main__":
main()



Above is the Python code the video gives a bit of an overview you will need to add the library's (pip install) stream deck , asyncio , web sockets

Also if it errors the HIDAPI plugin will need to be manually installed just google the installation process its straight forward I put them in system 32

You will need to configure QLC in web mode, The manual has a really good explanation on this https://www.qlcplus.org/old/docs/html_e ... rface.html

It worked on windows 11
Yestalgia
Posts: 371
Joined: Thu Jun 17, 2021 9:31 am
Location: Australia
Real Name:
Contact:

Sickkk
Post Reply