- openHAB version: 2.5M1
.items file:
Group gAutomaticLights
Switch Front_Porch_Light_Automatic (gAutomaticLights)
.rules file:
rule "Turn on porch light when dark"
when
Member of gAutomaticLights received command
then
logInfo("****TEST****", "**** 1 triggeringItem.state = " + triggeringItem.state + " receivedCommand = " + receivedCommand)
logInfo("****TEST****", "**** 2 triggeringItem.state = " + triggeringItem.state + " receivedCommand = " + receivedCommand)
end
I opened two openhab console connections over two separate windows. One session is to send command (smarthome:send) and the other session is running log:tail
In the command session, I sent:
smarthome:send Front_Porch_Light_Automatic OFF
smarthome:send Front_Porch_Light_Automatic ON
smarthome:send Front_Porch_Light_Automatic OFF
smarthome:send Front_Porch_Light_Automatic ON
smarthome:send Front_Porch_Light_Automatic OFF
smarthome:send Front_Porch_Light_Automatic ON
In the log, I saw - excuse the long log - I’ve edited for clarity - stripping off unnecessary parts of the log
Item 'Front_Porch_Light_Automatic' received command OFF
Front_Porch_Light_Automatic changed from NULL to OFF
**** 1 triggeringItem.state = OFF receivedCommand = OFF
**** 2 triggeringItem.state = OFF receivedCommand = OFF
Item 'Front_Porch_Light_Automatic' received command ON
Front_Porch_Light_Automatic changed from OFF to ON
**** 1 triggeringItem.state = OFF receivedCommand = ON
**** 2 triggeringItem.state = **ON** receivedCommand = ON
Item 'Front_Porch_Light_Automatic' received command OFF
Front_Porch_Light_Automatic changed from ON to OFF
**** 1 triggeringItem.state = OFF receivedCommand = OFF
**** 2 triggeringItem.state = OFF receivedCommand = OFF
Item 'Front_Porch_Light_Automatic' received command ON
**** 1 triggeringItem.state = ON receivedCommand = ON
**** 2 triggeringItem.state = ON receivedCommand = ON
Front_Porch_Light_Automatic changed from OFF to ON
Item 'Front_Porch_Light_Automatic' received command OFF
**** 1 triggeringItem.state = ON receivedCommand = OFF
**** 2 triggeringItem.state = **OFF** receivedCommand = OFF
Front_Porch_Light_Automatic changed from ON to OFF
Item 'Front_Porch_Light_Automatic' received command ON
**** 1 triggeringItem.state = OFF receivedCommand = ON
**** 2 triggeringItem.state = **ON** receivedCommand = ON
Front_Porch_Light_Automatic changed from OFF to ON
I have enclosed the anomalous “ON/OFF” with two stars. Basically the two logs **** 1
and **** 2
should match for triggeringItem.state. However, sometimes they don’t. The first one is correct, but the second one is incorrect, as though the state got updated (it shouldn’t). This behaviour is also a bit intermittent, so if you’re trying it, try doing several on/off/on/off
So, is this a bug? If not, what can I do? It seems that the workaround is to save the triggeringItem.state at the top of the rule in a variable and use that variable in the rest of the rule.
Has anyone noticed this?