I have a question regarding the usage of Exec 2 Binding. Suppose I have a script that receives a command (“ON” or “OFF”), controls a device (turns it on or off) and returns the execution result - the actual state of the device (again “ON” or “OFF”). The device can go offline or some errors could occur, so the command may fail and after receiving an “ON” command the script could actually return an “OFF” value and vice versa. It would be great if I could create an openHAB configuration where:
- a Switch changes it’s state when the user clicks on it;
- the script gets called and the state of the Switch is passed to it as an argument (“ON” or “OFF”) (Exec input channel is used);
- the script tries to turn on or off the the device and returns the result (“ON” or “OFF”) (I suppose Exec output channel must be used);
- the state of the Switch is updated according to the state returned from the script.
So basically the user clicks/taps on a Switch an if an error occurs the state of the Switch will not change. If everything is fine the Switch will change it’s state and the user can be sure the command succeeded.
I know that periodic polling of the actual device state could be used but that is not desired for many reasons.
Any help would be greatly appreciated.