Websocket request

I’m new to the PB and this forum. I must say I really like what’s been done with the PB and it’s working really well!

So, I finally got the Websocket to the PB working so I can integrate it with my OpenHAB gateway! It works very well, but I have a few requests to fine tune the integration.

  1. It works well with the pattern info frame being sent when changed. It would be great if the same could apply for the brightness level.

  2. Also, I fully understand the performance aspect of sending the pattern list/info binary. But, if it could also be requested in the “old” format, e.g through a “listProgramsJSON” command maybe?

    	"programList": [
    			"name": "my pattern",
    			"id": "x1234567890",
    			"sourceSize": 123,
    			"globalSourceSize": 123,
    			"compiledSize": 134,
    			"imgSize": 5123
    		}, ...
  1. When a Websocket connection is established, it would be great if the active pattern and current brightness level frame(s) could be sent - like a getStatus command (which also would be great)? Excellent when you have to do reboots or other stuff.


Hi @Zugarelli,
Welcome to the forum!

For #1 and #3, try sending a {getConfig: true} frame. This will give you both the current brightness and activeProgramId. It will give you a ton of other things as well, just about everything on the settings page. I might make a more focused API for that sometime in the future.

For #2, I had to drop the old format because it was running the ESP out of memory. It would need to be a chunked API that sent the list in multiple frames. I’ll think about it. Did you have trouble getting that working? What language are you working in to read the websocket frames?

OK, I’ll try that.
But, I don’t think that would be a very elegant solution since the bi-directional power of Websocket wouldn’t be used. This would be more like a http request and I would have to design some loop functionality polling the PB at regular intervals to check if something changed. I would prefer a push solution (as is for the pattern) where brightness gets pushed when changed. By doing so I will get an instant update in my backend and can do whatever I want when this happens - no delays :grinning:. If you could consider applying the same functionality to brightness push as you have for patterns, I’d really appreciate it.

I understand. I was just hoping to find a way to automatically retreive a list of available patterns, but I can do a manual copy. They only change so often. I wasn’t able to retreive the binary data so I dropped that one.

Actually I don’t know. I’m using the Node-RED web based flow editor and built-in logic. It’s available as optional sw install for OpenHAB and has pre-defined objects, both for OpenHAB items and Websocket connections. So, I basically just added a Websocket listener, parse the incoming value from the PB using a pre-defined JSON function and direct it to the correct item in OpenHAB. It’s a really powerful tool for a non-programmer like me. It works the other way as well, so I can change pattern and set brightness from my OpenHAB the same way.