Proposed Enhancements to Web Access

Post Reply
George Qualley

I've been getting into the web access portion of QLC+ lately and I have a couple of suggested enhancements that I might be able to get into the code if they sound good. To explain why I want what I'm thinking of, I'll give a little background on my situation.

For this particular project, I'm using QLC+ in my lounge so it is a permanent install. QLC+ controls a fair amount of the ambient accent lighting in addition to dance lighting. I also have an automation computer which runs Indigo (for Insteon, IR, etc). Although QLC+ has basic timed triggers, they are not nearly as robust or as flexible as those in Indigo (nor would I expect them to be). It would be very beneficial to me to be able to trigger certain scenes at certain times of the day. Which, of course, got me thinking: "how can I hook Indigo up to QLC+."

Luckily Indigo is very flexible and it supports a few scripting environments. One is Python and the other is Applescript. I initially looked at Python in hopes that I might be able to hook up a direct WebSocket connection to QLC+, but the version of Python included in Indigo is quite old and most of the WebSocket things I was finding for Python were unsupported under the relevant version. Add to that the fact that I don't know Python and I started looking at Applescript.

Now say what you want about Applescript, but many times, it's a pretty great tool to get things done. And, as it turns out, I can run JavaScript through a web browser using Applescript which should mean that I'm pretty close to being able to command QLC+ from Indigo. Except, as it turns out, there's one problem. I can toggle buttons in QLC+ like crazy, but I just haven't been able to figure out how to set a button to a discrete state (i.e. On/Off) using JavaScript. Now, I'm no Javascript so I had my brother take a look. Not that he's a Javascript expert, but he generally knows more than I do when it comes to this particular language.

One of the biggest problems it seems, is that QLC+ doesn't provide a way to directly get the state of a button. In talking to my brother, he indicates that it should be relatively easy to provide this and he's willing to see about putting it in QLC+ if no one else is willing to do so. In addition, it seems to me that it would be awfully nice if there was a straightforward way to set objects to discrete states with a simple web link--essentially an API. Again, I spoke with my brother about this and he seems to think that this would be fairly trivial.

Obviously, my use is somewhat exotic, but I can definitely see where one or both of these features could really open up some possibilities. Any thoughts on this?
Massimo Callegari

Hi George, this is an interesting point.
I decided to use a web based approach with web sockets because it was the most "cross platform" and standard way that I knew.
There are probably other ways like PHP or ASP but they require a lot more of code and then QLC+ would probably suffer of it.

Please keep in mind that when you load a web page, all the Javascript code is executed on the client side (so on your computer/tablet) and the client/server data exchange happens only through a websocket.

So right now it is only possible to request a webpage that represent the Virtual Console in HTML and all the Javascript code to handle events and communicate via websocket.

What I can do though, is to write a sort of "scripting language" that you can use in a generic way and design your own web pages to control QLC+. Obviously commands will still use the websocket way.

For example
- getFunctionsList
- getFunctionStatus
- getFunctionType
...and so on

Would that help what you have in mind ?

Also, do you have suggestions to improve the QLC+ Clock widget ?
Right now it does already a few things. What I plan to add is a weekly schedule, so you can start functions only on the selected days of the week.
George Qualley

Massimo,

From what little I know about websockets, I think your approach is the correct one. It's very responsive and seems to be very efficient. I've looked under the hood (so to speak) of the pages that QLC+ generates and I understand how the Javascript is interacting with the websockets. Like I said, I can control the buttons using buttonClick(buttonID).

I think your proposed language would be an excellent addition. It would definitely open up some big possibilities.

With respect to the clock widget, IMHO, the things that would make it useful in my situation are as follows:

1) The ability to turn scenes/chases/etc. off (as well as on)
2) The ability to run scenes at specific times on specific days (as you said).

Other than that, my needs aren't super rigorous and that would really cover it!
Massimo Callegari

George, I will implement those "API" then, but I think after 4.7.1.

As for the clock widget, functions can only be started because with chasers you can set their duration. So for example if you want to switch a light on at 9pm and switch it off at 5am, you just need to set the chaser step's duration to 8 hours and it will stop automatically.
George Qualley

Massimo,

Two things.

1) I can't wait for the API! Personally, I don't care if it's via web access or if I could just activate things from the command line. Either way, I have some fun things in mind for it!

2) Your explanation of the clock widget makes sense. I don't often use one shot chasers, so that possibility had escaped me. Thank you for the idea!
Willy_Pinguino

I think that would be fantastic to have a way to controll a server installation from another istance of QLC+ remotely.

My dream would be open my laptop, open my local istance of QLC+ and connect it to a server istance (maybe on a raspberry on the stage) where I can control the remote QLC+ core from the local QLC+ interface, opening and saving files, creating fictures and shows remotely using a local interface... or if it's impossible, creating a different interface from another application and using a websoket connection or a ssl connection to send comands from an app directly to the QLC+ core...

and near of it would be perfect have a protocoll or an interface to send and receive files (audio and video, show files and fixtures to send to and receive from the server), using a connection trough lan or an internet connection
George Qualley

Massimo,

You are amazing!
Massimo Callegari

George, in return I expect feedbacks on those APIs ! :)
Once you start getting the results you have in mind, please share them with us.
Thanks !
George Qualley

Massimo,

OK, here's the first thing I've noticed. First, let me say that I use a lot of collections. For me, I like them as kind of a way to structure my buttons. So for example, I'd have a bunch of buttons and each one of those buttons would be mapped essentially 1:1 to a collection. Because of this, I have noticed that vcWidgetSetValue doesn't seem to work correctly.

In my tests, if I run vcWidgetSetValue (using 255 as the value, of course), the button is toggled where I would expect it to either be turned on or stay on (if it is already on). I believe I can work around this using getWidgetStatus (which is really what I asked for in the first place) but I thought I'd let you know...
jannis87

Massimo about the current state of the simple desks and websockets: Does this work correctly on your machines? On my laptop, I see the simple desk sliders and I can move them but the movement on the web browser is not seen in the Qt GUI and movements of the sliders in the Qt GUI are not seen in the web browser. Is that a part that is still worked on (by you) or shall I try to debug/fix that myself? I'd just like to avoid duplicate work here.
Massimo Callegari

Hi Jannis, I've implemented the web simple desk together with the QLC+ web API to demonstrate how to move a single channel.
It is indeed perfectible.
I confirm what you found. Basically if you use the web access you don't use the Qt GUI and vice-versa.
Right now I'm working on some other areas, so please feel free to propose a patch on GitHub and then we'll discuss it.
Please be careful with CPU usage. Moving Simple Desk sliders on a PC might not have a big impact, but on the Raspberry Pi it can make the difference (maybe compromising a running Function)

Thanks
Post Reply