Script looping does not work

I am trying to build a script to turn on a pump for 5 minutes and turn it off for one hour.
I chekced the site: https://home-assistant.io/cookbook/automation_flashing_lights/

and came up with this code:

script:
  hydroponics_start:
    alias: Pumpenzyklus
    sequence:
      - alias: Pumpe_An
        service: switch.turn_on
        data:
          entity_id: switch.hydropump
      - delay: 00:00:03
      - alias: Pumpe_Aus
        service: homeassistant.turn_off
        data:
          entity_id: switch.hydropump
      - delay: 00:00:03
      - alias: Pumpe_Loop
        service: script.turn_on
        data:
          entity_id: script.hydroponics_start

But I get just one cycle and then an error saying:

17-02-10 21:20:44 WARNING (MainThread) [homeassistant.components.script] Script script.hydroponics_start already running.

What am I missing?

Ok, you want to use scripts to get this working. I have an example of a timed door that you may be able to piece apart. 1 timer required 2 scripts and 1 automation if my memory serves me:

automation:
- alias: Entry light trigger on entry door 
  trigger:
    - platform: state
      entity_id: sensor.entry_door_hindge
      to: 'open'
  condition:
    - condition: state
      entity_id: sun.sun
      state: "below_horizon"
  action:
    - service: homeassistant.turn_on
      entity_id: script.timed_entry

the scripts:

script:
  alias: Turn on Entry Lights for 2 Minutes
  sequence:
    # Cancel ev. old timers
    - service: script.turn_off
      data:
        entity_id: script.entry_timer_off
    - service: switch.turn_on
      data:
        entity_id: switch.entry_s_switch_17_0
    # Set new timer
    - service: script.turn_on
      data:
        entity_id: script.entry_timer_off

  alias: Start New Entry Light Timer
  sequence:
    - delay:
        minutes: 2
    - service: switch.turn_off
      data:
        entity_id: switch.entry_s_switch_17_0

When the automation calls the first script, the first script calls a timer-script that shuts it off after 2 minutes. This code was copied from separate config files so the spacing is probably off. You may need to adjust that. But the principle is the same.

Every hour call an automation:
The script starts a timer that last 5 minutes.

There is a for option that might be helpful.

something like

automation:
  trigger:
    platform: state
    entity_id: switch.hydropump 
    from: 'off'
    to: 'on'
    for: 
      "00:05:00"
  action:
    service: switch.turn_off
    entity_id: switch.hydropump
 
  trigger
    platform: state
    entity_id: switch.hydropump
    from: 'on'
    to: 'off'
    for:
      "01:00:00"
  action:
    service: switch.turn_on
    entity_id: switch.hydropump

my YAML is probably indented wrong and there may be some other errors, but I think it will get you going in the right direction.

Thank you. that works perfectly fine :slight_smile: