HI Guys, I’m struggling with an automation I have setup for greenhouse irrigation. I have a small plastic box with a float switch in it which also has a irrigation drip per which fills it when the irrigation starts. The idea is that once the box fills the float switch will trigger the irrigation pum to switch off and as the water evaporated from the box the float switch turns on and this is a condition for turning the greenhouse irrigation on again.
I have the following automation, which will trigger the irrigation to turn on but when the float switch turns off it is not triggering the pump to turn off.
I’m not quite sure why the above automation is not working as I expected?? I know that the float switch is changing state as I can see this in the history log. Today the pump ran and flooded my tomato’s
This State Condition within the automation’s action doesn’t wait around until the switch’s state becomes off.
- condition: state
entity_id: binary_sensor.float_switch
state: 'off'
When the automation reaches that State Condition and determines the switch’s state is currently on it ends the automation immediately. That’s how a condition within an action behaves.
If you want it to wait until the switch is off, consider using a wait_template.
Be advised that the way you constructed the automation makes it vulnerable to being interrupted by a restart or Reload Automations. If you are interested, I can explain how to make it more fault-tolerant.
Thanks @123 I’ve updated the wait template and added a timeout, which I assume with allow the automation to continue after the timeout even if the wait template condition is not met? is that correct?
Also if you could share how to make this automation more fault tolerant that would be great, thanks
You should specify a timeout value. The wait_template waits for the float switch to turn off for no longer than the duration of the timeout value (and then either continues or terminates, depending on the value of continue_on_timeout).