Hi,
I have a rule used when setting my house to “goodnight” mode. Basically it turns of some lights, turns of the tv etc.
Problem is that I wan’t to leave 2 lights on during the night - in my current rule I turn of all lights (GLights), create a delay (12s) and turn on the 2 nightlights. However, very often the 2 nightlights end out being turned off despite the 12s delay…
Can anyone see why this happens in my rule or alternatively direct me towards a better solution?
Thank you!
var Timer timergodnat
rule "hus status"
when
Item HouseDummy received command
then
if (receivedCommand==0) {
sendCommand(Samsung_TV, OFF)
sendCommand(GMusic, OFF)
sendCommand(LgTvPower, ON)
GLights.sendCommand(OFF)
Siri_Goodnight.postUpdate(ON)
Siri_Normal.postUpdate(OFF)
Siri_Away.postUpdate(OFF)
Siri_Ferie.postUpdate(OFF)
Markise.sendCommand(UP)
timergodnat = createTimer(now.plusSeconds(12), [|
Lys_PH.sendCommand(ON)
Lys_Stue_tradfri.sendCommand(ON)
])
}
end rule
You’ve no guarantees what order commands get processed in by bindings, when you issue a lot at once.
Why not make another Group containing all the lights you want to turn off except the ones you want to leave on? Items can be members of several Groups.
GLights.members.forEach[i|
i.sendCommand(
if(i.name != "Lys_PH" && i.name != "Lys_Stue_tradfri")
OFF
else
ON
)
]
All members of GLights get a OFF command, except the two Items Lys_PH and Lys_Stue_tradfri, which get the command ON instead.
Please keep in mind, that sometimes a lot of simultaneous commands can lead to command loss (openHAB sends too fast and the binding can’t buffer all commands)
Yep-i have thought of that as well which would work. I was just getting stubborn, as I can’t understand why my initial rule doesn’t work. But it’s probably, as you say, because I can’t control the order.
Thanks👍