Thermostat automation: Script needs streamlining

It’s easy to use repeat for this purpose. The service call will be repeated only the number of times necessary or until it reaches a maximum number of attempts.

For added robustness, add an if-then after the repeat to check if the service call was ultimately successful. If it wasn’t then, at a minimum, post a notification reporting the failure.


FWIW, I have a ‘goodnight’ script that runs through a long list of things to lock, turn off, etc. For my situation, it doesn’t employ repeat (to try multiple times) but a wait_for_trigger with a timeout. For example, after locking a doorlock, it waits for the lock’s state to change to ‘locked’. If it fails to change within the timeout period, the script announces the failure (and then proceeds to execute the balance of the script).

1 Like