- Platform information:
- openHAB version: 2.2
- Issue of the topic:
I have 4 LIFX lights which I want to toggle on and off thru the Double Press action of my wireless button.
The 4 lights are in 2 separate rooms so the Short Press action of the buttons toggles 2 lights and the Long Press toggles the other 2.
Because its possible for another device to change the state of the lights (Lifx app, Google Home etc) I have catered for the fact that 2 of the lights might have a different state and if so set both of them on.
var fr1_state = Family1_Switch.state
var fr2_state = Family2_Switch.state
logInfo("RULES", "Family 1 State " + fr1_state)
logInfo("RULES", "Family 2 State " + fr2_state)
if (fr1_state != fr2_state) {
logInfo("RULES", "Lights are in different states - TURNING ON")
Family1_Switch.sendCommand("ON")
Family2_Switch.sendCommand("ON")
}
This works ok so my challenge now is how to compare the state of all 4 lights to see if they differ?
Now I could compare light 1 to 2, 1 to 3 and 1 to 4, but its a bit ugly. Is there a better way anyone can suggest?
if (fr1_state != fr2_state OR fr1_state != br1_state OR fr1_state != br2_state) {...
Thanks for any suggestions,
Clearly not a programmer