I have a set of three LIFX bulbs which I want to change (on/off/color, etc) simultaneously.
This is possible through the LIFX app, and through third-party apps that make use of the LIFX LAN Protocol.
So far I’ve been unable to accomplish this, but I wanted to open a new thread now that I (hopefully) understand the challenge is parallelism and the Event Bus.
My understanding now is that sendCommand is synchronous and limited to a single thread by the Event Bus, and postCommand is asynchronous and limited by the max threads available to the Event Bus.
The LIFX Binding doesn’t seem to use postCommand, instead preferring sendCommand (a good choice if you could only pick one).
Where I’m stuck now is that any way I try to change the lights (sendCommand, REST API, JSR233, etc), I’m always bottle-necked by the Event Bus to a single thread. This is true even if I map multiple Things (channels) to a single Item.
Is there any solution for multi-threading this?
EDIT: I want to add that I tried multi-threading by creating separate rules which execute at a single DateTime. Unfortunately, the result here was that only one light was changed, at random.
When I staggered the DateTime by 1ms for each rule, the lights changed one-by-one at the same speed as using sendCommand to each individually.
It sounds like you have all but answered your own question. The binding needs to implement postCommand.
That sounds like a bug and should be reported. We should be able to have any number of rules trigger at the same time whether it is through a DateTime trigger or any other event.
Does it also occur if you have lots of rules that all get triggered by the same event (e.g. a Proxy switch turning ON)?
Yes, the timers were triggered by a switch.
Should I report that on the OpenHAB github? Smarthome Eclipse? As an issue with the LIFX binding, or the core?
And how would I properly make a request for the binding to implement postCommand - would that be opening an issue on the Smarthome Eclipse github, or is that reserved for bugs?
Appreciate all your help Rich.
I think all the bindings are hosted here: https://github.com/openhab/openhab2-addons. That is where any issues (I guess this is really a feature request) would take place for the LIFX binding itself.
The fact that multiple rules are not executing when triggered from the same Time cron event would probably be an ESH issue. Before opening an issue there, go to their forums and open a discussion.
It was fixed years ago and it works very well with the LIFX binding nowadays. It can still be an issue in other bindings if they don’t properly schedule the execution of long running commands in new threads.
On the multiple same-time cron issue, it should be resolved in 2.5 for both cron rule triggers and createTimer() calls.