I seem to be getting an extra execution of my rule with a received command trigger. I’m running version 2.5 docker image on a Synology NAS.
The rule:
var int garage_status = 0
rule "Garage Door Workaround"
when
Item DoorGarage received command
then
if (receivedCommand == ON){
if (garage_status == 1){
logInfo("Doors", "Garage door ON command, needs to be off")
garage_status = 2
DoorGarage.sendCommand(OFF)
}
else if (garage_status == 0){
logInfo("Doors", "Garage door ON command normal")
garage_status = -1
}
}
else {
if (garage_status == 0){
logInfo("Doors", "Garage door OFF command, already off")
garage_status = 1
}
else{
garage_status = 0
}
}
logInfo("Doors", "Garage door is now " + Long.toString(garage_status))
end
The DoorGarage item is a light switch using the Lutron binding. Alarm.com turns this virtual light switch on and off with the door. This rule is to workaround that alarm.com will issue the OFF command before the ON command sometimes. The events log for a test case:
2021-09-03 15:19:40.523 [ome.event.ItemCommandEvent] - Item 'DoorGarage' received command OFF
2021-09-03 15:19:40.524 [nt.ItemStatePredictedEvent] - DoorGarage predicted to become OFF
2021-09-03 15:19:45.713 [ome.event.ItemCommandEvent] - Item 'DoorGarage' received command ON
2021-09-03 15:19:45.714 [ome.event.ItemCommandEvent] - Item 'DoorGarage' received command OFF
2021-09-03 15:19:45.720 [nt.ItemStatePredictedEvent] - DoorGarage predicted to become ON
2021-09-03 15:19:45.726 [nt.ItemStatePredictedEvent] - DoorGarage predicted to become OFF
2021-09-03 15:19:45.731 [vent.ItemStateChangedEvent] - DoorGarage changed from OFF to ON
The openhab.log:
2021-09-03 15:19:41.638 [INFO ] [eclipse.smarthome.model.script.Doors] - Garage door OFF command, already off
2021-09-03 15:19:41.640 [INFO ] [eclipse.smarthome.model.script.Doors] - Garage door is now 1
2021-09-03 15:19:45.712 [INFO ] [eclipse.smarthome.model.script.Doors] - Garage door ON command, needs to be off
2021-09-03 15:19:45.714 [INFO ] [eclipse.smarthome.model.script.Doors] - Garage door is now 2
2021-09-03 15:19:45.716 [INFO ] [eclipse.smarthome.model.script.Doors] - Garage door is now 0
2021-09-03 15:19:45.887 [INFO ] [eclipse.smarthome.model.script.Doors] - Garage door OFF command, already off
2021-09-03 15:19:45.888 [INFO ] [eclipse.smarthome.model.script.Doors] - Garage door is now 1
So each execution of the rule prints the “Garage door is now…” line. There are 4 of them. In the openhab.log there are only 3 received command lines. Why isn’t the extra command in the events.log?
My speculation is the command goes to the Lutron binding which issues the command to the Lutron system. The system response with a message to the binding, and it can’t tell if it’s an update from it’s own command or a command from the lighting system, so it issues another command. Or is there some other reason my rule executes twice for the OFF command?