Indeed. And even if the Group worked it will send the commands out in sequence so either way performance will be a pain.
First you might be able to get the Group approach to work if you define your group as follows:
Group:Dimmer:AVG gLight_BG_hal_12_Dimmer
This gives OH the hint that you want to treat this Group as if it were a Dimmer Item. Of course make sure not to put non-dimmers into this group. Also note that the value of this Dimmer Group will be the average of all the members. There are other options you can use (see this) but I think AVG is appropriate in this context, though MIN or MAX make sense too. I’ve never done this with a Dimmer so I don’t know what it would default to.
NOTE: I’ve found it useful to distinguish Groups from Items by prepending a g to their name
Next, @tommycw10’s approach is pretty much what I would do but you can use the fact that you have a Group to your advantage and make the rule simpler:
rule "dim them all"
when
Item All_Hue_Lights received command // trigger on the virtual switch
then
gLight_BG_Hal_12_Dimmer.members.forEach[ dmr | dmr.sendCommand(All_Hue_Lights.state) ]
end
Finally, and this should work in theory (what a wonder place that Theory is) but I’ve not tried it myself. You can use Timers to add some parallel processing so the lights will get sent their commands in parallel. Honestly in this context I’m not sure if this will work or not as I don’t think its the rule that is the bottleneck. Anyway, it is probably too much overhead to create a timer for each sendCommand so I would group them.
1 create some subgroups and put three to five of your dimmers in each subgroup. Put each subgroup into Light_BTG_Hal_12_Dimmer. Do not put ANY actual dimmers into Light_BTG_Hal_12_Dimmer.
Dimmer All_Hue_Lights // virtual dimmer to trigger the rule, put this on your sitemap
Group Light_BG_Hal_12_Dimmer // parent group
Group Light_BG_Hal_12_Dimmer1 (Light_BG_Hal_12_Dimmer) // child group
Group Light_BG_Hal_12_Dimmer2 (Light_BG_Hal_12_Dimmer) // child group
Group Light_BG_Hal_12_Dimmer3 (Light_BG_Hal_12_Dimmer) // child group
Dimmer Light_BG_hal_12hue1 (Light_BG_hal_12_Dimmer1, BG_Hal,Lights,Lights_BG) {hue="7"}
Dimmer Light_BG_hal_12hue2 (Light_BG_hal_12_Dimmer1, BG_Hal,Lights,Lights_BG) {hue="13"}
Dimmer Light_BG_hal_12hue3 (Light_BG_hal_12_Dimmer1, BG_Hal,Lights,Lights_BG) {hue="10"}
Dimmer Light_BG_hal_12hue4 (Light_BG_hal_12_Dimmer1, BG_Hal,Lights,Lights_BG) {hue="9"}
Dimmer Light_BG_hal_12hue5 (Light_BG_hal_12_Dimmer2, BG_Hal,Lights,Lights_BG) {hue="15"}
Dimmer Light_BG_hal_12hue6 (Light_BG_hal_12_Dimmer2, BG_Hal,Lights,Lights_BG) {hue="8"}
Dimmer Light_BG_hal_12hue7 (Light_BG_hal_12_Dimmer2, BG_Hal,Lights,Lights_BG) {hue="11"}
Dimmer Light_BG_hal_12hue8 (Light_BG_hal_12_Dimmer2, BG_Hal,Lights,Lights_BG) {hue="12"}
Dimmer Light_BG_hal_12hue9 (Light_BG_hal_12_Dimmer3, BG_Hal,Lights,Lights_BG) {hue="14"}
Dimmer Light_BG_hal_12hue10 (Light_BG_hal_12_Dimmer3, BG_Hal,Lights,Lights_BG) {hue="16"}
Dimmer Light_BG_hal_12hue11 (Light_BG_hal_12_Dimmer3, BG_Hal,Lights,Lights_BG) {hue="18"}
Dimmer Light_BG_hal_12hue12 (Light_BG_hal_12_Dimmer3, BG_Hal,Lights,Lights_BG) {hue="17"}
2 change the above rule’s body to this:
val newState = All_Hue_Lights.state // grab it once so we don't slow down below grabbing it over and over
Light_BTG_Hal_12_Dimmer.members.forEach[grp |
createTimer(now.plusMillis(1), [| grp.members.forEach[dmr | dmr.sendCommand(newState)])
]
The way this works is you iterate over all the members of Light_BTG_Hal_12_Dimmer (which are all Groups themselves). For each subgroup we create a timer that will immediately start executing in the background. When that timer starts executing we iterate over all the members of that subgroup and send the Dimmer the new command.
Some words of warning:
- there is some overhead to creating a thread. This may actually make things worse, not better. You can fine tune it though by adding more Items to fewer subgroups or more subgroups with fewer items each. The nice thing is you can do all of this in your items file.
- I don’t own a Hue hub, I know nothing about Hue and I have no idea if this will disturb, damage, or destroy your hub. Most devices can manage fast messages like this but YMMV. Proceed with caution.
- I just typed this in. Expect typos.