Automation not stopping

I have an automation that fires up a irrigation water pump each 2 hours. This automation works very well. I have a second automation to stop the watering that triggers like this:

entity_id: switch.tau2_water_pump
for: '00:02'
from: 'off'
platform: state
to: 'on'

This second automation works most of the time, but it happens from time to time that it doesn’t trigger… my guess is that it doesn’t see the off to on switch, hence it doesn’t trigger and then it doesn’t stop the watering. How can I implement this better ? maybe attach the trigger on the first automation ? yesterday it did water for all the night :frowning:

In the end, I want the irrigation to water for 2 minutes and then stop. What’s the best way to implement this ?

Remove the from: 'off' line. It may have turned on from ‘unavailable’.

It would be helpful to post your entire automations. As it is we have to guess a lot. But I think something like the following might work for you:

- trigger:
  - platform: time_pattern
    hours: "/2"
  action:
  - service: switch.turn_on
    entity_id: switch.tau2_water_pump
  - delay:
      minutes: 2
  - service: switch.turn_off
    entity_id: switch.tau2_water_pump
1 Like

The delay is exactly what I was searching. Thanks a lot pnbruckner.