QLC+, API, websockets and Python3
Posted: Sat Jun 01, 2024 2:08 pm
Hello everybody,
i'll excuse in advance but im digging trough Google and the forum for a week now and slowly turn insane on this topic.
Maybe i dont understand some things, ask the wrong questions or miss some trivial things.
Please bear with me, i'm something on beginner-advanced level in python.
Situation:
Roughly half a year ago i built an interactive device with an RPi 3B, an RFID scanner and some audio files running on python together with VLC-lib.
Basically each RFID tag was connected to a certain audio file, which was played then.
It worked fine and was kinda sucessfull, so i though to turn it up a bit.
Plan:
Trigger some lighting scenes with it too.
So i got the RPi5 (RPi OS Bookworm), RPi QLC+ version and a DMX interface.... in stand alone conditions everything is cool.
But now i tried to extend my python script and make it to communicate with QLC+.
As far as i understood, the fastest way is to connect the API via websocket and there the problems began:
No matter what i try, the shell keeps nagging with various errors which i dont really understand even when i try some code snippets from the forum.
Could someone explain it to me like i'm a complete dummy please?
Basically i tried something like that:
Anyone an idea?
i'll excuse in advance but im digging trough Google and the forum for a week now and slowly turn insane on this topic.
Maybe i dont understand some things, ask the wrong questions or miss some trivial things.
Please bear with me, i'm something on beginner-advanced level in python.
Situation:
Roughly half a year ago i built an interactive device with an RPi 3B, an RFID scanner and some audio files running on python together with VLC-lib.
Basically each RFID tag was connected to a certain audio file, which was played then.
It worked fine and was kinda sucessfull, so i though to turn it up a bit.
Plan:
Trigger some lighting scenes with it too.
So i got the RPi5 (RPi OS Bookworm), RPi QLC+ version and a DMX interface.... in stand alone conditions everything is cool.
But now i tried to extend my python script and make it to communicate with QLC+.
As far as i understood, the fastest way is to connect the API via websocket and there the problems began:
No matter what i try, the shell keeps nagging with various errors which i dont really understand even when i try some code snippets from the forum.
Could someone explain it to me like i'm a complete dummy please?
Basically i tried something like that:
Code: Select all
import websockets
websockets.connect('ws://QLC-IP:9999/qlcplusWS') # Web interface is up and running smoothly
if a_certain_condition_is_met = true:
websockets.send("start a particular scene") # Shell tells me, there is no "send" in websockets-lib so maybe i do something wrong or use the wrong documentation