I’m trying to set up a group switch to turn on/off all my lights in one room using an item and corresponding rule. For some reason, once the switch is activated either off or on, the events.log shows that the lights get stuck in a loop continually sending the same on/off command. Also, is there some clear documentation of the available commands for openHAB rules? I’ve been searching everywhere for explanations on how to use gGroup.members.forEach(...)
and what the ‘?’ does when used with gGroup.members.forEach
does? I’ve seen some example code on this forum and on the GitHub wiki with and without the ‘?’
Here’s my current setup:
plaintext
home.items:
Group Living_Room “Living Room” (All)
Group Living_Room_Lights “Lights” (Living_Room)
Switch Living_Room_Lights_All “Living Room Lights” (Living_Room_Lights)
home.rules:
rule “Living Room Group Light Switch”
when Item Living_Room_Lights_All received update
then
if(Living_Room_Lights_All.state == ON)
Living_Room_Lights?.members.forEach(item | sendCommand(item, ON))
else
Living_Room_Lights?.members.forEach(item | sendCommand(item, OFF))
end
And here’s what the events.log shows:
plaintext
2016-08-13 10:39:36 - Light_GF_Living_Room_Table received command ON
2016-08-13 10:39:36 - Light_GF_Living_Room_Floor received command ON
2016-08-13 10:39:36 - Living_Room_Lights_All received command ON
… (repeats multiple times)
I’ve tried removing the ‘?’ and adjusting the rule logic, but the issue persists. Any insights or suggestions would be greatly appreciated! I’m really looking forward to getting this working smoothly.