Hello again, first off as those here already know, QLCplus is one great program, thank you Massimo! Also thanks to him I have QLC running on the pi desktop.
My programming strength is Python but weak on the Linux so please excuse.
For this project I would like my Python script to send commands to QLC. From what I have read the way to do this is through OSC. Assuming that is correct I attempted to load OSC on the pi, but when I import osc Python says the package doesn't exist. If I tell Linux to load osc again
$ sudo -H pip3 install python-osc
It says that it is already installed in Python 3.
I have searched for information on this and seemingly there are various OSC packages out there so I'm not even sure this is the proper one, or even, if this is the best approach to controlling QLC from Python.
Thanks for any help, once I get back to Python I shouldn't have to ask so many questions.
QLCplus control by Python
- mcallegari
- Posts: 4807
- Joined: Sun Apr 12, 2015 9:09 am
- Location: Italy
- Real Name: Massimo Callegari
- Contact:
There are web API. Much simpler than creating OSC packets
https://www.qlcplus.org/Test_Web_API.html
https://www.qlcplus.org/Test_Web_API.html
-
- Posts: 6
- Joined: Tue Feb 01, 2022 8:40 pm
- Real Name: Robert
Hello,
I'm looking for a way to launch QLC+ scenes from an external program.
The QLC+ Web API Test page works fine, but I couldn't transpose the javascript to a text command line .
I'm mostly interested in the websocket connection and the getFunctionsList and setFunctionStatus functions.
Does anyone have a piece of python code to share?
Thank you very much
I'm looking for a way to launch QLC+ scenes from an external program.
The QLC+ Web API Test page works fine, but I couldn't transpose the javascript to a text command line .
I'm mostly interested in the websocket connection and the getFunctionsList and setFunctionStatus functions.
Does anyone have a piece of python code to share?
Thank you very much
- sbenejam
- Posts: 616
- Joined: Sun Apr 12, 2015 6:28 pm
- Real Name: Santiago Benejam Torres
- Contact:
I made some weeks ago some tests with python against QLC+ API. I hope it's helpful.
Code: Select all
import asyncio
import websockets
async def test():
async with websockets.connect('ws://10.32.234.136:9999/qlcplusWS')
as websocket:
await websocket.send("QLC+API|" + "getWidgetsList")
response = await websocket.recv()
widgets=[]
# ~ print(text.split('|'))
llista=iter(response.split('|')[2:])
for i in llista:
# ~ print(i, next(llista))
widget=[i, next(llista)]
widgets.append(widget)
# ~ print(widgets)
for i in widgets:
await websocket.send("QLC+API|" + "getWidgetType" + '|' + i[0])
response = await websocket.recv()
print (i[0], response.split('|')[2])
asyncio.get_event_loop().run_until_complete(test())