Sprinkler variable delay duration if zone is enabled

I’ve been slowly building an automation to run my sprinklers that are connected to an indexing valve. I only turn the pump on an off, and it automatically advances to the next zone when going from on to off.

Recently I created some helpers to let me set the start time and how long each zone is on.

The next piece I’d like to add is the ability to “disable” zones. I use disable in quotes beacuse to disable the zone I’d just have it on for a short time, like 15 seconds, then turn it off, to basically skip watering that zone and move on to the next one.

I plan to add binary helpers for enabling each zone, but the part I need help on is how to use that binary helper value to determine the delay duration. So if the binary help is enabled use the helper duration I set via UI, and if it’s disabled use 15 seconds for the delay between turning it on and off.

Any help would be appreciated. Here’s what I have looks like so far.

alias: Run Sprinkler
description: ""
trigger:
  - platform: time
    at: input_datetime.sprinkler_start_time
condition:
  - condition: time
    weekday:
      - mon
      - wed
      - fri
action:
  - type: turn_on
    device_id: ec8a16b109434163a8e1ddec73f84491
    entity_id: 4c77fdd52d150176461c75f65011b666
    domain: switch
  - delay:
      hours: 0
      minutes: "{{ states('input_number.zone_1_duration') | int }} "
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: ec8a16b109434163a8e1ddec73f84491
    entity_id: 4c77fdd52d150176461c75f65011b666
    domain: switch
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - type: turn_on
    device_id: ec8a16b109434163a8e1ddec73f84491
    entity_id: 4c77fdd52d150176461c75f65011b666
    domain: switch
  - delay:
      hours: 0
      minutes: "{{ states('input_number.zone_2_duration') | int }} "
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: ec8a16b109434163a8e1ddec73f84491
    entity_id: 4c77fdd52d150176461c75f65011b666
    domain: switch
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - type: turn_on
    device_id: ec8a16b109434163a8e1ddec73f84491
    entity_id: 4c77fdd52d150176461c75f65011b666
    domain: switch
  - delay:
      hours: 0
      minutes: "{{ states('input_number.zone_3_duration') | int }} "
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: ec8a16b109434163a8e1ddec73f84491
    entity_id: 4c77fdd52d150176461c75f65011b666
    domain: switch
mode: single
1 Like

do you mean like this?
if boolean named enable_zone1 is true it will use your zone_1_duration, otherwise it will do 15 seconds

      minutes: "{{ states('input_number.zone_1_duration') | int  if states('input_boolean.enable_zone1') else 0 }}"
      seconds: "{{ 0 if not states('input_boolean.enable_zone1') else 15 }} "

use this in the delay block for zone 1 and replicate the format for the other zones.

1 Like

Thanks! I’ll give this a try today and see how it works. I had some issues last time it ran where it didn’t turn off after the delay from the helper value. So it looks like I have some debugging to do.