[esphome] max run time for my irrigation

I am running my irrigation off a wemos d1 mini running esphome controlled by HA. This works great.
But now I am trying to create a failsafe in case HA turned on the irrigation and for some reason (network down or HA down, whatever) it never closes the valves.
What I am thinking of is a max run time implementation, I think this should be possible using automations inside esphome (NOT HA!). But I am not sure how to implement this. Any ideas on that?

1 Like

Hi there,

How did you go with this? I’m facing the same issue. I can see this emptying my rainwater tanks if there is no failsafe…

B

Sorry for the extreme late answer. I didn’t find a way to do this inside esphome.
I ended up creating an automations rule like:

  alias: water backyard failsafe
  trigger:
  - entity_id: switch.water_backyard
    for: 00:30:00
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: switch.water_backyard
    service: homeassistant.turn_off

Here’s one way I have done it. I have a hot water cycling pump on my water heater that I don’t want to accidentally run forever. So I have a delay setup in my ESPHome code that turns it back off after 10 minutes.

      - switch.turn_on: relay
      - delay: 10min
      - switch.turn_off: relay

See the full code here: https://github.com/brianhanifin/esphome-config/blob/7dd2d0e2b0a050cfef452550785bd3c4cfca5967/plug05.yaml#L72

If you’re using GPIO switch, I believe you can just use on_turn_on with a delay. That way you don’t need to convert it to a template switch or anything else.

# Zone 1
  - platform: gpio
    name: "Irrigation Zone 1"
    pin:
      number: GPIO3 #RX
      inverted: true
    id: zone_1
    restore_mode: ALWAYS_OFF
    # Interlock to prevent more than one zone active at a time
    interlock: &interlock_group [zone_1, zone_2, zone_3, zone_4, zone_5]
    # Set automatic timeout 10 minutes
    on_turn_on:
      then:
        - delay: 10min
        - switch.turn_off: zone_1
2 Likes

Oh… I like the simplicity! Thanks for sharing.