Help controlling multiple dimmers as one

Recently installed three sets of zwave dimmers for the kitchen counter lighting. I want to control all three as one for toggling ON/OFF as well as Dimming from both the UI. I would also like to do the same using the physical dimmer but I can deal with that after getting the UI portion functioning. In regards to the UI, there is no need to control these dimmers separately so some kind of virtual item will work fine. I’ve read lots of posts and this seems to be a common scenario but I haven’t been able to pin down the best way to do this.

Appreciate the help!

1 Like

Well, the easiest way to do this, is building a group and an item for each dimmer:

Group:Dimmer MyDimmer
Dimmer MyDimmer1 "Dimmer1" (MyDimmer) {...}
Dimmer MyDimmer2 "Dimmer2" (MyDimmer) {...}
Dimmer MyDimmer3 "Dimmer3" (MyDimmer) {...}

Now use a rule:

var lock = false

rule "equalize dimmer"
when
    Member of MyDimmer received command
then
    if(!lock) {
        lock=true
        MyDimmer.members.filter[d|d.name<>triggeringItem.name].forEach[d|d.sendCommand(receivedCommand)]
        Thread::sleep(200)
        lock=false
    }
end

The rule will trigger each time a dimmer is changed, regardless if via UI or wall rocker. the rule will test for other running instances (!lock) and if there is no other instance, will lock the rule and send the received command to each dimmer of the group (without the one which triggered the rule, as this dimmer has already received the command). After that it will wait 200mSec to ensure all triggers were done, finally it will unlock the rule.

2 Likes

Hi @Udo_Hartmann
Out of curiosity wky do you use the lock the Thread::sleep?

Thanks @Udo_Hartmann, I’ll give that a try.

@Udo_Hartmann your instructions were great and I’m able to control the lights from one Dimmer in the UI. I’m having an issue with the physical dimmer as its not sending state make to openHAB when changed. It may be an issue with the dimmer. I’m reading through another thread to find out more.

One this I did need to change in your example was the <> to !=.

Thanks Again

That’s because the items don’t receive a command when toggled at the switch, just a state update, so you need to use the changed trigger. Note that the receivedCommand variable isn’t available then, so you have to use triggeringItem.state instead.

var lock = false

rule "equalize dimmer"
when
    Member of MyDimmer changed
then
    if(!lock) {
        lock=true
        MyDimmer.members.filter[d|d.name!=triggeringItem.name].forEach[d|d.sendCommand(triggeringItem.state)]
        Thread::sleep(200)
        lock=false
    }
end
1 Like

An alternative would be to configure association groups if your dimmer support sending the dim value.

Actually the Dimmers (Qubino Z-Wave Plus Flush Dimmer ZMNHDD3) were not sending anything back to openHAB when toggling the physical switch. After a bunch of research I determined this could be fixed by updating the Association Group of the Thing by adding “Controller” to the Multilevel Association Group. Once I did that, for all three dimmers, the starting sending their states back to openHAB.

I then figured, if the Dimmer can send its State back to the Controller why not see if it can send its State to the other Dimmers. So I started with one other Dimmer adding each other to the Multilevel Association Group.

Using PaperUI update Things:

  • Dimmer1: Multilevel Association Group = Controller, Dimmer2
  • Dimmer2: Multilevel Association Group = Controller, Dimmer1

Then I went and deactivated the rule but left some logging on so I could see what was happening. To my delight, this worked, well kind of. Dimmer1 did in fact set Dimmer2 to match its state, but then Dimmer2 sent its state back to Dimmer1 which then caused a crazy light show which proceeded until I removed one of the associations. I’m sure there’s a way around this, like the Lock in the rule but at least I had learned some cool capability that I was not aware of.

So where did it all end up…

Chose one of these dimmers as the master and the other two as slaves with the intention that I would only use the Master in any UI as well as Physical Location.

Physical Switch
For each of the Slave locations, I replaced the Switch (each was actually a combo Switch/Outlet) with an Outlet leaving the ZMNHDD3 in box. This ended up having one Switch for the Counter Lights and added two additional outlets which made my wife happy.

Things:
Kitchen Counter Light (node53): Multilevel Association Group=Controller, node54, node55
Kitchen Counter Light Slave1 (node54): Multilevel Association Group=Controller
Kitchen Counter Light Slave2 (node55): Multilevel Association Group=Controller

Items
Group AllLights
Group SwitchLights (AllLights)
Group DimmerLights (AllLights)

Switch Switch_Kitchen_Counter (SwitchLights)
Switch Switch_Kitchen_Counter_Slave1 (SwitchLights)
Switch Switch_Kitchen_Counter_Slave2 (SwitchLights)

Dimmer Dimmer_Kitchen_Counter (DimmerLights)
Dimmer Dimmer_Kitchen_Counter_Slave1 (DimmerLights)
Dimmer Dimmer_Kitchen_Counter_Slave2 (DimmerLights)

Rule

var lock = false

rule "equalize switches"
when
    Member of SwitchLights received command
then
    if(!lock) {
        lock=true
        SwitchLights.members.filter[d|d.name != triggeringItem.name].forEach[d|d.sendCommand(receivedCommand)]
        Thread::sleep(200)
        lock=false
    }
end

rule "equalize dimmers"
when
    Member of DimmerLights received command
then
    if(!lock) {
        lock=true
        DimmerLights.members.filter[d|d.name != triggeringItem.name].forEach[d|d.sendCommand(receivedCommand)]
        Thread::sleep(200)
        lock=false
    }
end

Conclusion

  • The Rule controls the equalization of the Switches and Dimmers when changed by openHAB.
  • The Multilevel Association Group controls the equalization of the Switches and Dimmers when changed by the Physical Switch.

Everything is working exactly as intended. There’s likely more that can be done here, but man did I learn a bunch last night. Crawled into bed around 2:30AM.

Special thanks to @Udo_Hartmann, @pacive and the openHAB Community!

1 Like