Run action in parallel

I have the following automation for my sprinklers.

switch:
- platform: command_line
  switches:
    bw_beet_ost:
      friendly_name: Beete vorne
      command_on: "ssh pi2 -C /usr/local/bin/bus.py 35 18 1 1"
      command_off: "ssh pi2 -C /usr/local/bin/bus.py 35 18 1 0"
    bw_rasen_sued_ost:
      friendly_name: Rasen vorne/seite 
      command_on: "ssh pi2 -C /usr/local/bin/bus.py 35 18 2 1"
      command_off: "ssh pi2 -C /usr/local/bin/bus.py 35 18 2 0"
    bw_hochbeet:
      friendly_name: Hochbeet
      command_on: "ssh pi2 -C /usr/local/bin/bus.py 35 18 3 1"
      command_off: "ssh pi2 -C /usr/local/bin/bus.py 35 18 3 0"
    bw_rasen_hinten:
      friendly_name: Rasen hinten
      command_on: "ssh pi2 -C /usr/local/bin/bus.py 35 18 4 1"
      command_off: "ssh pi2 -C /usr/local/bin/bus.py 35 18 4 0"
    bw_bambus_thujen_beeren:
      friendly_name: Bambus/Thujen/Beeren
      command_on: "ssh pi2 -C /usr/local/bin/bus.py 35 18 6 1"
      command_off: "ssh pi2 -C /usr/local/bin/bus.py 35 18 6 0"
    bw_blumenbeet:
      friendly_name: Blumenbeet
      command_on: "ssh pi2 -C /usr/local/bin/bus.py 35 18 5 1"
      command_off: "ssh pi2 -C /usr/local/bin/bus.py 35 18 5 0"
    bw_nebler_terrasse:
      friendly_name: Nebler Terrasse
      command_on: "ssh pi2 -C /usr/local/bin/bus.py 35 18 1 1"
      command_off: "ssh pi2 -C /usr/local/bin/bus.py 35 18 1 0"

input_slider:
  sprinklerhour:
    name: Sprinkler Hour
    icon: mdi:timer
    initial: 6
    min: 0
    max: 23
    step: 1
  sprinklerminutes:
    name: Sprinkler Minutes
    icon: mdi:timer
    initial: 30
    min: 0
    max: 60
    step: 1
  bw_beet_ost:
    name: Beet vorne
    icon: mdi:timer-sand
    initial: 30
    min: 0
    max: 60 
    step: 1
  bw_bambus_thujen_beeren:
    name: Bambus/Thujen/Beerenbeet
    icon: mdi:timer-sand
    initial: 30
    min: 0
    max: 60 
    step: 1
  bw_blumenbeet:
    name: Blumenbeet
    icon: mdi:timer-sand
    initial: 30
    min: 0
    max: 60 
    step: 1
  bw_rasen_sued_ost:
    name: Rasen vorne/seite
    icon: mdi:timer-sand
    initial: 10
    min: 0
    max: 60
    step: 1
  bw_hochbeet:
    name: Hochbeet
    icon: mdi:timer-sand
    initial: 20
    min: 0
    max: 60
    step: 1
  bw_rasen_hinten:
    name: Rasen hinten
    icon: mdi:timer-sand
    initial: 20
    min: 0
    max: 60
    step: 1


automation:
  - alias: 'Sprinkler Schedule'
    initial_state: false
    trigger:
     - platform: template
       value_template: '{{ now().hour == (states.input_slider.sprinklerhour.state  | round(0))  and  now().minute == (states.input_slider.sprinklerminutes.state  | round(0) )  }}'
    action:
#Tropfschläuche
#bw_beet_ost
      - service: homeassistant.turn_on
        data:
          entity_id:
            - switch.bw_beet_ost
      - delay: '00:{{ states.input_slider.bw_beet_ost.state | int }}:00'
      - service: homeassistant.turn_off
        data:
          entity_id:
            - switch.bw_beet_ost
#bw_bambus_thujen_beeren
      - service: homeassistant.turn_on
        data:
          entity_id:
            - switch.bw_bambus_thujen_beeren
      - delay: '00:{{ states.input_slider.bw_bambus_thujen_beeren.state | int }}:00'
      - service: homeassistant.turn_off
        data:
          entity_id:
            - switch.bw_bambus_thujen_beeren
#bw_blumenbeet
      - service: homeassistant.turn_on
        data:
          entity_id:
            - switch.bw_blumenbeet
      - delay: '00:{{ states.input_slider.bw_blumenbeet.state | int }}:00'
      - service: homeassistant.turn_off
        data:
          entity_id:
            - switch.bw_blumenbeet
#bw_hochbeet
      - service: homeassistant.turn_on
        data:
          entity_id:
            - switch.bw_hochbeet
      - delay: '00:{{ states.input_slider.bw_hochbeet.state | int }}:00'
      - service: homeassistant.turn_off
        data:
          entity_id:
            - switch.bw_hochbeet
#bw_rasen_sued_ost
      - service: homeassistant.turn_on
        data:
          entity_id:
            - switch.bw_rasen_sued_ost
      - delay: '00:{{ states.input_slider.bw_rasen_sued_ost.state | int }}:00'
      - service: homeassistant.turn_off
        data:
          entity_id:
            - switch.bw_rasen_sued_ost
#bw_rasen_hinten
      - service: homeassistant.turn_on
        data:
          entity_id:
            - switch.bw_rasen_hinten
      - delay: '00:{{ states.input_slider.bw_rasen_hinten.state | int }}:00'
      - service: homeassistant.turn_off
        data:
          entity_id:
            - switch.bw_rasen_hinten

which runs one sprinkler after another.

But I want to start some sprinklers in parallel, each for there own delay time, and after all of them are finished, continue with the others in serial.

Is there a way to do this?

I found a workaround and split the automation, all starting at the same time. The sprinkler which should run exclusively are added to the automation with the longest duration.
That’s working fine as long as this duration isn’t changed, so it’s working but not very sexy.

input_slider:
  sprinklerhour:
    name: Sprinkler Hour
    icon: mdi:timer
    initial: 7
    min: 0
    max: 23
    step: 1
  sprinklerminutes:
    name: Sprinkler Minutes
    icon: mdi:timer
    initial: 0
    min: 0
    max: 60
    step: 1
  bw_beet_ost:
    name: Beet vorne
    icon: mdi:timer-sand
    initial: 20
    min: 0
    max: 60 
    step: 1
  bw_bambus_thujen_beeren:
    name: Bambus/Thujen/Beerenbeet
    icon: mdi:timer-sand
    initial: 30
    min: 0
    max: 60 
    step: 1
  bw_blumenbeet:
    name: Blumenbeet
    icon: mdi:timer-sand
    initial: 20
    min: 0
    max: 60 
    step: 1
  bw_rasen_sued_ost:
    name: Rasen vorne/seite
    icon: mdi:timer-sand
    initial: 10
    min: 0
    max: 60
    step: 1
  bw_hochbeet:
    name: Hochbeet
    icon: mdi:timer-sand
    initial: 0
    min: 0
    max: 60
    step: 1
  bw_rasen_hinten:
    name: Rasen hinten
    icon: mdi:timer-sand
    initial: 20
    min: 0
    max: 60
    step: 1


automation:
- alias: 'Bewässerung bw_bambus_thujen_beeren_rasen'
  initial_state: true
  trigger:
   - platform: template
     value_template: '{{ now().hour == (states.input_slider.sprinklerhour.state  | round(0))  and  now().minute == (states.input_slider.sprinklerminutes.state  | round(0) )  }}'
  condition:
    condition: state
    entity_id: input_boolean.bw_on_off
    state: 'on'
  action:
    - service: homeassistant.turn_on
      data:
        entity_id:
          - switch.bw_bambus_thujen_beeren
    - delay: '00:{{ states.input_slider.bw_bambus_thujen_beeren.state | int }}:00'
    - service: homeassistant.turn_off
      data:
        entity_id:
          - switch.bw_bambus_thujen_beeren
    - service: homeassistant.turn_on
      data:
        entity_id:
          - switch.bw_rasen_sued_ost
    - delay: '00:{{ states.input_slider.bw_rasen_sued_ost.state | int }}:00'
    - service: homeassistant.turn_off
      data:
        entity_id:
          - switch.bw_rasen_sued_ost
    - service: homeassistant.turn_on
      data:
        entity_id:
          - switch.bw_rasen_hinten
    - delay: '00:{{ states.input_slider.bw_rasen_hinten.state | int }}:00'
    - service: homeassistant.turn_off
      data:
        entity_id:
          - switch.bw_rasen_hinten


- alias: 'Bewässerung bw_beet_ost'
  initial_state: true
  trigger:
   - platform: template
     value_template: '{{ now().hour == (states.input_slider.sprinklerhour.state  | round(0))  and  now().minute == (states.input_slider.sprinklerminutes.state  | round(0) )  }}'
  condition:
    condition: state
    entity_id: input_boolean.bw_on_off
    state: 'on'
  action:
    - service: homeassistant.turn_on
      data:
        entity_id:
          - switch.bw_beet_ost
    - delay: '00:{{ states.input_slider.bw_beet_ost.state | int }}:00'
    - service: homeassistant.turn_off
      data:
        entity_id:
          - switch.bw_beet_ost


- alias: 'Bewässerung bw_blumenbeet' 
  initial_state: true
  trigger:
   - platform: template
     value_template: '{{ now().hour == (states.input_slider.sprinklerhour.state  | round(0))  and  now().minute == (states.input_slider.sprinklerminutes.state  | round(0) )  }}'
  condition:
    condition: state
    entity_id: input_boolean.bw_on_off
    state: 'on'
  action:
    - service: homeassistant.turn_on
      data:
        entity_id:
          - switch.bw_blumenbeet
    - delay: '00:{{ states.input_slider.bw_blumenbeet.state | int }}:00'
    - service: homeassistant.turn_off
      data:
        entity_id:
          - switch.bw_blumenbeet


- alias: 'Bewässerung bw_hochbeet'
  initial_state: true
  trigger:
   - platform: template
     value_template: '{{ now().hour == (states.input_slider.sprinklerhour.state  | round(0))  and  now().minute == (states.input_slider.sprinklerminutes.state  | round(0) )  }}'
  condition:
    condition: state
    entity_id: input_boolean.bw_on_off
    state: 'on'
  action:
    - service: homeassistant.turn_on
      data:
        entity_id:
          - switch.bw_hochbeet
    - delay: '00:{{ states.input_slider.bw_hochbeet.state | int }}:00'
    - service: homeassistant.turn_off
      data:
        entity_id:
          - switch.bw_hochbeet