Hi
i have a sonoff dual where i set by Tasmota an interlock.
The update of the status is not correct. Infact when i turn ON a switch the other must be at OFF. On sonoff is so but in openhab is not so.
I want to create a rule to do it.
I created this but doesn’t work:
rule "interlock1"
when
item LivingRoom_Light1 received command
then
if (receivedCommand == ON) LivingRoom_Light2.sendCommand(OFF)
else LivingRoom_Light2.sendCommand(ON)
end
rule "interlock2"
when
item LivingRoom_Light2 received command
then
if (receivedCommand == ON) LivingRoom_Light1.sendCommand(OFF)
else LivingRoom_Light1.sendCommand(ON)
end
rule "interlock1"
when
Item LivingRoom_Light1 received update
then
if ( LivingRoom_Light1.state == ON)
LivingRoom_Light2.sendCommand(OFF)
else
LivingRoom_Light2.sendCommand(ON)
end
rule "interlock2"
when
Item LivingRoom_Light2 received update
then
if (LivingRoom_Light2.state == ON)
LivingRoom_Light1.sendCommand(OFF)
else
LivingRoom_Light1.sendCommand(ON)
end
the sonoff has gone mad. alternately and incessantly lit the two relè
Look thay
2019-03-17 22:00:13.451 [ome.event.ItemCommandEvent] - Item 'LivingRoom_Light1' received command ON
2019-03-17 22:00:13.477 [vent.ItemStateChangedEvent] - LivingRoom_Light1 changed from OFF to ON
2019-03-17 22:00:14.319 [ome.event.ItemCommandEvent] - Item 'LivingRoom_Light1' received command OFF
2019-03-17 22:00:14.336 [vent.ItemStateChangedEvent] - LivingRoom_Light1 changed from ON to OFF
2019-03-17 22:00:15.356 [ome.event.ItemCommandEvent] - Item 'LivingRoom_Light2' received command ON
2019-03-17 22:00:15.366 [nt.ItemStatePredictedEvent] - LivingRoom_Light2 predicted to become ON
2019-03-17 22:00:15.376 [vent.ItemStateChangedEvent] - LivingRoom_Light2 changed from OFF to ON
2019-03-17 22:00:16.239 [ome.event.ItemCommandEvent] - Item 'LivingRoom_Light2' received command OFF
2019-03-17 22:00:16.246 [nt.ItemStatePredictedEvent] - LivingRoom_Light2 predicted to become OFF
2019-03-17 22:00:16.254 [vent.ItemStateChangedEvent] - LivingRoom_Light2 changed from ON to OFF
2019-03-17 22:00:17.120 [ome.event.ItemCommandEvent] - Item 'LivingRoom_Light2' received command ON
2019-03-17 22:00:17.132 [nt.ItemStatePredictedEvent] - LivingRoom_Light2 predicted to become ON
2019-03-17 22:00:17.143 [vent.ItemStateChangedEvent] - LivingRoom_Light2 changed from OFF to ON
2019-03-17 22:00:17.935 [ome.event.ItemCommandEvent] - Item 'LivingRoom_Light2' received command OFF
2019-03-17 22:00:17.943 [nt.ItemStatePredictedEvent] - LivingRoom_Light2 predicted to become OFF
2019-03-17 22:00:17.957 [vent.ItemStateChangedEvent] - LivingRoom_Light2 changed from ON to OFF
The problem is that if i set by Tasmota the interlock the update in openhab is not correct
So i’d like to create e rule to update the state in real time
rule "interlock1"
when
Item LivingRoom_Light1.state changed to ON
then
LivingRoom_Light2.sendCommand(OFF)
end
You can do the second one yourself.
Reason for changes, trigger only when the state really changed to ON and do nothing when it changed to OFF. The constant switching was probably caused by reacting on EACH update.
If you just want to check the state and update then something like this may work.
rule "interlock1"
when
Item LivingRoom_Light1 received update or
Item LivingRoom_Light received update
then
if ( LivingRoom_Light1.state == ON)
LivingRoom_Light1.postUpdate(ON)
if ( LivingRoom_Light2.state == ON)
LivingRoom_Light2.postUpdate(ON)
You’ll need to add the OFF part but on each update the state will be checked.
rule "interlock1"
when
Item LivingRoom_Light1.state changed to ON
then
LivingRoom_Light2.sendCommand(OFF)
end
rule "interlock2"
when
Item LivingRoom_Light2.state changed to ON
then
LivingRoom_Light1.sendCommand(OFF)
end
Try the rule without the item state in the when section.
Example:
rule "interlock1"
when
Item LivingRoom_Light1 changed to ON
then
LivingRoom_Light2.sendCommand(OFF)
end
rule "interlock2"
when
Item LivingRoom_Light2 changed to ON
then
LivingRoom_Light1.sendCommand(OFF)
end
If that doesn’t work you might want to create a proxy item, add it to your sitemap, and test with the proxy that something is working.
Example:
rule "interlock1"
when
Item Proxy_switch changed to ON
then
LivingRoom_Light1.sendCommand(ON)
end
rule "interlock2"
when
Item Proxy_switch changed to ON
then
LivingRoom_Light1.sendCommand(OFF)
end
After testing LivingRoom_Light1, try with LivingRoom_Light2, if neither work then there is something else going on with the OH setup.