What is the proper way to sequence two or more automations?

Hello all, 3 month newb here, making progress learning albeit very slowly sometimes!

Hoping to learn the proper (or perhaps the most efficient) way of running 2 or more automations (or maybe they should be scripts) in sequence???

So this is for multiple relay switched water valves that I already have working from my home sprinkler system that I needed to adopt into HA when my BHyve timer dumped out last month. Will attempt to post the automation yaml that I got running last night (and I only have the one “zone” automation currently done but now I’ve figured out how to do it so it should be easy to duplicate.

Please ignore the parts about the WLED light cycling, I have been trying to incorporate indicator lights representing different sequences for my water zones and “Pool Fill” was the first “zone” chosen…

But yes all input appreciated as to how best to call out 2, 3, or maybe 4 of these automations in sequence for a scheduled lawn watering event. Also maybe notable might be that I have soil moisture sensors on order and hope to incorporate data from that esp32 circuit into sprinkler functioning. Also also well aware that this has been done many times with various integrations? but my skill level is not to the point of adapting third party routines into my system, perhaps with more learning! thanks to all, here is my code…

alias: Pool Fill Process
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.util_water_relays_esp8266_pool_fill
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 1
condition: []
action:
  - service: select.select_option
    target:
      entity_id: select.wled_preset
    data:
      option: BlinkWhite
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: select.select_option
    target:
      entity_id: select.wled_preset
    data:
      option: GradientPink
  - delay:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
  - service: select.select_option
    target:
      entity_id: select.wled_preset
    data:
      option: BlinkWhite
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - type: turn_off
    device_id: 05dfd10bc7a5c625bed7ceec2588ea81
    entity_id: 0341f515f5ba5003ed5d00992a9ad9f5
    domain: switch
  - service: select.select_option
    target:
      entity_id: select.wled_preset
    data:
      option: SlowerRainbow
mode: single

Doing that is not advised. It is too easy to interrupt automations if they are waiting in delays for long periods of time.

One way you could approach this is to trigger the next relay when the previous one turns off. Personally I just use a weekly schedule helper (from the UI not YAML) for each irrigation valve to trigger from and when programming the times I make sure they don’t overlap.

The only issue here is that the minimum on time you can specify is 30 minutes. So I use a separate input number run time for turning off.

Thanks much for the reply! Just tried a schedule helper and while I see your half hour minimum I dont see but only one entity reference at the bottom which is itself?

What would be the worst case scenario of using delays of longer frames in automaitons??? I do not have tons of them and none overlap due to water flow rate logistics…

Several years ago, someone asked for a means of controlling an irrigation system using a state-machine approach. I provided the following solution:

Each zone is modeled by three entities:

  1. Input Boolean for manually disabling/enabling a zone
  2. Input Datetime to specify how long a zone should operate.
  3. Switch to control the zone’s valve.

The example I posted uses an Input Boolean instead of a Switch because it makes it easier to test its operation (without controlling actual valves).

It uses an Input Select for specifying the system’s mode of operation (you can use an automation based on a Schedule entity to control the Input Select’s mode).

All this to say that a single automation can control the sequential operation of multiple irrigation zones (and you can manually, or programmatically, control which zones should be watered).

Thanks much! Very interesting, my limited programming skills were unaware that basic entities could include such things.

I do feel my code is fairly redundant in that it is merely a highly overwritten zone timer BUT I so badly wanted to incorporate the WLED light presets into the various timer sequence stages, I found it within automations and just kinda rolled with it lol

But now I just want to make sure I’m “doing it the right way”