Loxone Support Community

Find answers, ask questions and become part of the Loxone Community.

Loxone Support CommunityCategory: GeneralCommunicating using websockets
3 years ago
Communicating using websockets

Does anyone have any examples of how I can communicate with an external device using websockets. The device is a PixelBlaze V2 LED pixel controller.

9 Answers
3 years ago

Hi Stephen

Without exact details on the websocket API in question the below is a generalisation.

I imagine what you will be looking for is Virtual Outputs. For example lets say you have to send a command over TCP (typically used for websockets).

The IP address to send to is 192.168.1.100

Then the command is POWERON

You will need to create a Virtual Output in config, under the address parameter you will fill in tcp://192.168.1.100

Next you need to create a Virtual Output Command under this output. Under the parameters of the command, you will want the Command for ON to be /POWERON

From here simply drag out your Virtual Output Command and use as required.

Otherwise if you require some form of authentication with the websocket and to then hold the connection, you may need to do this via a PicoC script.

KR

Hugh

3 years ago

Many thanks, for your reply, I will be looking into it this weekend. Bit busy at the moment.

If you are interested here is the basic PixelBlaze documentation https://www.bhencke.com/pixelblaze-advanced

3 years ago

What I have found so far –

So to access the Pixel Blaze you send the websocket command:

ws://192.168.1.100:81

To list the patterns (only needed once to find out the code for the desired patterns.

{ "listPrograms": true }

Then to change patterns you issue the following command

{ "activeProgramId": "LjdRmpPdaZPEdbHhM" }

I have tried in Loxone but can’t seem to get it to work. I did think I might be able to write a pico C script but not too sure where to start.

3 years ago

Hi Stephen

So if we are actually using websocket communications these might be a touch more difficult as websocket is a defined protocol with a request/response outline that may not be possible within Virtual Outputs.

Unfortunately as the program block requires a strong knowledge of script language C (which I don’t have) I will have to leave to the rest of the community to see if anyone can help.

KR
Hugh

3 years ago

THanks for your help. Need to start learning Pico C I guess.

3 years ago

hi Stephen

I’ve been playing around with http vi/vo commands in Loxone and found some interesting articles in the German public Loxone forums – it’s worth taking a look at them. Based on what I read there, I managed to get my Loxone system to control my Kodi (XBMC) media server – the api requirements don’t look too different to what you need being based on JSON.

Take a look at the example JSON command sent to the server (it’s sending a Play media request). You might be able to adapt it to what you need. One problem I’ve not yet solved is how to handle responses – so if you need to query and be able to read a text response through the UI, I don’t think Loxone will handle it.

Good luck and post some results if you make progress!

Attachments
3 years ago

Unfortunately while your suggestions where quite good and I hope they would point me in the right direction. http commands don’t work and need to start with ws://ipaddress:81 . So tried using ws:// etc but that doesn’t work either. I have discovered something called Firestorm . But I am having problems just installing this on my Ubuntu laptop.

I am sure I can come up with something. Might email the developer of the PixelBlaze and see if he can add control via http.

3 years ago

Still can’t get it to work in Loxone. But I am a step nearer. If I enter

http://192.168.1.101:3000/command?command=%7B%22programName%22%3A+%22sparks%22%7D&ids=3601529 into a browser this changes the PixelBlaze to the pattern sparks

The http command is a Get command but I just can’t seem to get it to work in Loxone.

I did contact the developer of PixelBlaze and he is going to look at the possibility of adding an http api in a V3 update. The V3 boards are on pre order I should be getting mine in Feb, I am currently using a V2 board. Anyway I will carry on trying.

3 years ago

hi – try changing the command to POST.

3 years ago

No still doesn’t work.

3 years ago

Got it working.

The whole command

/command?command=%7B%22programName%22%3A+%22sparks%22%7D&ids=3601529

gets placed in the command for on. Which I wasn’t doing

Then HTTP method for on is POST everything is either empty or left as is.

Now Loxone can control my PixelBlaze

3 years ago

Good job!