Websocket not working as expected

Got my pixelblaze updated to v2.23
… and have been able to successfully communicate with it using websocat command line tool (windows x64) like so…

websocat ws://192.168.xx.xx:81/

and I can get a list of programs (saved patterns) back after sending…
{“listPrograms”: true}

but using the program ID I’m not able to get a pattern to actually start after sending either/both commands such as…
{“activeProgramID”: “FozMDMfBx3Cmau95D”}
{“activeProgram”:{“activeProgramId”:“FozMDMfBx3Cmau95D”,“controls”:{}}}

What am I missing?
P.S. also tried connecting as websocat ws://192.168.xx.xx:81/ -b (for binary) or -t for text but that didn’t help.

1 Like

Hi @jpm,
You are close, but I think a few small things caused it to not work.

It looks like those are smart quotes, not the straight quotes used in JSON format. If you are using a word processor, they tend to convert them to smart quotes automatically. A text editor designed for coding can be helpful there, like Sublime Text, VS Code, Atom, etc.

The other small thing is the capitalization on Id - it’s a lowercase ‘d’ and won’t work otherwise.

You’ll want the first form, the second form is an event that is sent out when the pattern actually changes, rather than a command to make it change.

Adding the -b for binary mode will cause it to treat text as binary, and won’t try to parse it as JSON, so leave that off.

e.g.

websocat  ws://192.168.4.1:81/

I send:

{"activeProgramId": "QqZqNsLmk2CAvheRR"}

and get this back:

{"activeProgram":{"activeProgramId":"QqZqNsLmk2CAvheRR","controls":{}}}
1 Like

I knew it was going to be something simple/silly. Capital D in ID was my bad!
Not sure how the smart quotes got inserted (forum software or firefox perhaps) but I am sending strait quotes.

Thank for such a quick response, it works.

I’ve been using your devices for various things - absolutely awesome - here’s a quick video of a bridge shelf I made: https://www.youtube.com/watch?v=CwZOQVQF3ek

This websocket communication helps me ensure it will turn on/off via HomeSeer motion sensor also in the room, and the bridge turns all green when the Laundry is done (Laundry is on the second floor and I often forget about/can’t hear it in my office)

2 Likes

Thanks, and thats awesome! Great build quality, and I like the diffusion! Pretty cool that you got the top lights going too.

Thats a great use too, what a nice indicator!