I’m trying to setup 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 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 ‘?’
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
events.log:
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
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
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 - Light_GF_Living_Room_Table received command ON
2016-08-13 10:39:36 - Living_Room_Lights_All 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
2016-08-13 10:39:37 - Light_GF_Living_Room_Table received command ON
2016-08-13 10:39:37 - Light_GF_Living_Room_Floor received command ON
2016-08-13 10:39:37 - Light_GF_Living_Room_Table received command ON
2016-08-13 10:39:37 - Living_Room_Lights_All received command ON
2016-08-13 10:39:37 - Light_GF_Living_Room_Floor received command ON
2016-08-13 10:39:37 - Living_Room_Lights_All received command ON
2016-08-13 10:39:37 - Light_GF_Living_Room_Table received command ON
2016-08-13 10:39:37 - Light_GF_Living_Room_Floor received command ON
2016-08-13 10:39:37 - Light_GF_Living_Room_Table received command ON
2016-08-13 10:39:37 - Living_Room_Lights_All received command ON
2016-08-13 10:39:37 - Light_GF_Living_Room_Floor received command ON
2016-08-13 10:39:42 - Living_Room_Lights_All received command OFF
2016-08-13 10:39:53 - Light_GF_Living_Room_Floor received command OFF
2016-08-13 10:39:54 - Light_GF_Living_Room_Table received command OFF