Automation repeat until condition

Hi,

I try to configure the follwing watering automation.

Start to run the watering after rain starts for 3 mins and the water level is high enough. (This is easy and I made it already) Now the automation should repeat if it’s still raining and water level is above a certain level. If it’s not raining or the water level is too low, the automation should stop running again.

The switch I use turning automatically off after 15 min. (Shelly)

Hope explained good enough.
Maybe I’m completely wrong. And I have to use 2 automations? IDK.

This is my code so fare:

alias: Gewächshaus Bewässerung bei Regen
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.regensensor
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 3
      seconds: 0
condition:
  - condition: state
    entity_id: switch.steckdose_gewachshaus
    state: "off"
    enabled: true
  - condition: state
    entity_id: binary_sensor.schwellwert_zisterne
    state: "on"
action:
  - repeat:
      sequence:
        - service: switch.turn_on
          metadata: {}
          data: {}
          target:
            entity_id: switch.steckdose_gewachshaus
        - delay:
            hours: 0
            minutes: 17
            seconds: 0
            milliseconds: 0
      until:
        - condition: state
          entity_id: binary_sensor.schwellwert_zisterne
          state: "off"
        - condition: state
          entity_id: binary_sensor.regensensor
          state: "off"
    enabled: true
mode: single

What exactly is your problem?

I think the wait for trigger action would be alot better in this situation. With repeat it repeatedly sends the on command to the lights until the condition is met which is unnecessary network traffic.

Thanks for your answer.

Maybe the problem is, that the switch (which is triggered by the automation) turns automatically off after 15 minutes. It’s a shelly switch with internal setting to turn off after 15 minutes.
Therefore, in my understanding, the automations should start after 17 Minutes again and check if all conditions still met to turn on the switch.

Idk how to do it with the wait for trigger.

I assume you are doing this as a fail-safe measure?

There’s no need for a repeat action.

Just add another state trigger to your existing automation that triggers when the Shelly turns from on to off.

Add conditions to check that it is raining and the water level is high enough.

Your action is only to turn the switch on.

Add a second automation to turn the switch off if it stops raining or the water level gets too low.

1 Like

Yes. right. But not for the HA. just when I use the physical switch in the garden.

I changed as proposed, now I just have to wait for rain. :smile: