Because I specified the command_state value it is used for feedback - i.e. to change the on/off state according to the actual state of the device.
Sometime, it happens that the command_on (or command_off) is sent, but for any reason the board doesn’t toggle its state. This isn’t a fault of HA, of course! But is there a way to tell HA to retry if the command didn’t work?
If I click on a switch in the page I can manually retry after few seconds, but it’s annoying when it happens in automation.
As far as I’m aware there is no built-in way to do this.
I’ve had similar issues with my Nest devices, so I came up with a way to do this. It’s a bit more complicated than this use case, so here’s the basic idea:
Use one of the first scripts to turn the switch on or off instead of changing the switch directly. You might need to do a bit more to deal with the situation where the relay’s state never changes like it should (e.g., add a counter to the “loop” and stop if it gets too big and maybe send a notification, etc.)
Got it. Yes, it gets quite complex soon, while it would be simple enough if handled natively.
Right now I’m going to use this approach only for most important switches. I hope the developers will try to get HA more reliable and begin to use feedbacks to close the control-loop!