Guy, let me rephrase. Basically i want two switches to always have the same state. Either both of them on, or bith of them off. Now using any insteon inter device links and dont want to. Want to achieve this with openhab.
Looked through the rule example and could not find help there. Yes, i can combine two rules into one and check the state, but that would not eliminate the infinite loop.
Ok, got it. Looks like I can make one rule to be based on received command and another based on received update to break the loop.
I have one more question. Is there a property like “DesiredState” available? Lets say the state of a switch is OFF and I want to turn it on by sending the command ON. Until the confirmation of the switch state change is delivered the state of the switch will remain OFF, right? Is there another property which will hold the state ON, meaning that within OpenHab the last command to set the state was ON.
The other option, and the one that I use, is instead to use the postUpdate function for the item you want to control.
This is how I do it:
Item KeyPadButton received command
if (Switch.state != KeyPadButton.state)
Item Switch received command
if (KeyPadButton.state != Switch.state)
That eliminates all the if statements, streamlines the code execution, and reduces the number of rules you need. And it keeps everything perfectly in sync. I’m using Insteon switches and keypads all over my house and this is how I keep everything in sync.
The key difference is that commands and updates are two different things. A device and receive an update without receiving a command, but if it receives a command it automatically receives and update.