If elif question

i’m new on home assistant, and i got in trouble to solve a problem
i’m having a small well in my garden which supplies only small amount water at once. I installed a water tank, which level is controlled by an ultrasonic sensor, it works fine, but i have to turn off the pump in the well if the flow rate goes low, and wait 30 minutes to have the well filled again, and start it over.
i tried to create a loop, which turns of the pump when the storage tank pulse counter value less than 30000, but i can’t imagine how to put another commands (delay 30min, and switch.turn_on and delay again 1 min)

wellpump_run:
  alias: Wellpump Flow control
  sequence:
    - service: switch.turn_on
      data:
        entity_id: switch.wellpump
    - delay: 00:01:00
    - alias: Repeat as log as conditions are true
      repeat:
        while:
          - condition: numeric_state
            entity_id: sensor.storage_tank_ultrasonic_sensor
            above: 0.23
        sequence:
          - service_template: >
              {% if (is_state("sensor.storage_tank_pulse_counter" < 30000)) -%}
              - switch.turn_off
              {%- else -%}
              switch.turn_on
              {%- endif %}
            data:
              entity_id: switch.wellpump

which is missing: after the switch turned off, we have to wait 30 minutes, and after that the switch turn on, and wait another 1 min

it seems i’ve already solved the problem :slight_smile: