Automation stops at repeat step

Hello everybody,

I’m quite new with HA and this is my first post on this site.

This is where I would like some help: I made an automation for my sprinkle system in the garden. There are 4 zones the first one needs 30min watering and the other 3 only 15min. After 3 days without rain the automation starts at 5:30.

So far it works, I receive a message that it has started but the automation stops before the repeat step. Only zone 1 is watered and then nothing.

This is what I came up with:

alias: Start sproeiers
description: ""
trigger:
  - platform: state
    entity_id:
      - input_boolean.sproeien
    from: "off"
    to: "on"
condition: []
action:
  - service: notify.mobile_app_iphone_carl
    data:
      title: BEWATERING
      message: |
        Sproeien gestart om {{ now().strftime("%H:%M:%S (%d %b %y)") }}
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.sproeiers
  - delay:
      hours: 0
      minutes: 30
      seconds: 0
  - service: switch.turn_off
    target:
      entity_id: switch.sproeiers
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
  - repeat:
      count: 3
      sequence:
        - service: switch.turn_on
          target:
            entity_id: switch.sproeiers
          data: {}
        - delay:
            hours: 0
            minutes: 15
            seconds: 0
        - service: switch.turn_off
          target:
            entity_id: switch.sproeiers
          data: {}
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
  - service: input_number.set_value
    data:
      value: 0
    target:
      entity_id: input_number.dagen_zonder_regen
  - service: notify.mobile_app_iphone_carl
    data:
      title: BEWATERING
      message: |
        Sproeien klaar om {{ now().strftime("%H:%M:%S (%d %b %y)") }}
  - service: input_boolean.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.sproeien
mode: single

In the log I find this:

Stopped because an error was encountered at August 7, 2024 at 06:00:10 (runtime: 1810.01 seconds)

Thanks in advance,
Carl

Hi, welcome to the forums. Please format your code correctly. See point 11 here. How to help us help you - or How to ask a good question

Even if you manage to get this automation running you have a serious issue with delays.
Every time you delay an automation you risk the switch/state/device to stay in the stat it is.
When you water the garden then all of the sudden HA reboots and the automation just ends, that means you will flood the neighborhood.

It’s a lot better to start the watering, then trigger on the watering being on for a certain time and switch off.
With that setup the code isn’t in a delay for hours.
Even if HA reboots, worst case is that you get double the amount of water on the garden.

Thank you both for the quick reply’s!

I’ll try to edit my post so it looks better. Also thanks for the tip, I’ll adjust the automation.

1 Like