That is really only relevant for long delays. Yours is only a minute.
Your off automation suffers the same issue. The for time won’t work after a restart.
The only way around this is to set an input datetime +1 minute from now() when you turn the switch on. Then use a time trigger to turn off the switch at that time.
Unfortunately as your restart time may be greater than one minute (hence my leading question) this off automation may miss the off time too. So not really worth doing, unless you also trigger an automation on restart of home assistant and check if the input datetime is in the past.
I have 11 zones in my irrigation system and I use this. I water for short amount of time for multiple cycles which helps with water consumption and minimizes. I have input variables that control start and duration of each zone. My maximum zone time is 15 minutes and most are set to 5 minutes. This may be more than you want to do.
- id: 'xxxxxxxxxxxxx'
alias: Water Lawn with repeat
description: Water all zones with repeat
trigger:
- platform: time
at:
- input_datetime.cycle1
- input_datetime.cycle2
- input_datetime.cycle3
- input_datetime.cycle4
- input_datetime.cycle5
- input_datetime.cycle6
condition:
- condition: state
entity_id: sensor.watering_days
state: '0'
- condition: state
entity_id: input_boolean.run_irrigation
state: 'on'
action:
- repeat:
count: '11'
sequence:
- variables:
zone: switch.zone_{{ repeat.index }}
- service: switch.turn_on
target:
entity_id: '{{ zone }}'
- delay:
minutes: '{{ states(''input_number.zone'' ~ repeat.index) | int }}'
- service: switch.turn_off
target:
entity_id: '{{ zone }}'
mode: single
# Boolean to control irrigation
input_boolean:
run_irrigation:
name: irrigation control
# initial: true - keep value through reboot so that is why commented out
icon: mdi:water-pump
I have a rainmachine that is controlled locally and the switches are named zone[1…11].
I use garbage collection to determine watering days S, T, Th every week between April and October. I also have a shutoff valve that I control with a separate automation.
- id: 'yyyyyyyyyyyyyy'
alias: 'Water Lawn - Turn on/off main water '
trigger:
- platform: time
at: input_datetime.irrigation_valve_on_morning
- platform: time
at: input_datetime.irrigation_valve_on_evening
- platform: time
at: input_datetime.irrigation_valve_off_morning
- platform: time
at: input_datetime.irrigation_valve_off_evening
condition:
- condition: state
entity_id: sensor.watering_days
state: '0'
- condition: state
entity_id: input_boolean.run_irrigation
state: 'on'
action:
- choose:
- conditions:
- condition: time
after: input_datetime.irrigation_valve_on_morning
before: input_datetime.irrigation_valve_off_morning
sequence:
- service: switch.turn_on
target:
entity_id: switch.irrigation_current_value
- conditions:
- condition: time
after: input_datetime.irrigation_valve_on_evening
before: input_datetime.irrigation_valve_off_evening
sequence:
- service: switch.turn_on
target:
entity_id: switch.irrigation_current_value
- conditions:
- condition: time
after: input_datetime.irrigation_valve_off_morning
before: input_datetime.irrigation_valve_on_evening
sequence:
- service: switch.turn_off
target:
entity_id: switch.irrigation_current_value
- conditions:
- condition: time
after: input_datetime.irrigation_valve_off_evening
sequence:
- service: switch.turn_off
target:
entity_id: switch.irrigation_current_value
default:
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 10
mode: single
I do not have much trouble keeping my system alive so the reboots are minimized.