Hi there!
How can I program a scheduled pattern of on/off cylces?
I need to water my greenhouse manually about once a month to clean out an excess of salt in soil (rest of the time is scheduled/automatic).
The automation should look like that: Trigger (Manual/ virtual switch) —> 10 minutes on (watering) —> 20 minutes off (pause) —> 10 minutes on (watering) —> 20 minutes off (pause) —> 10 minutes on (watering) —> 20 minutes off (pause).
I really tried to find something myself, but did not find a solution.
Can somebody give me a hint how to solve this?
Thank You!
Best regards,
Felix
Does this pattern continues for more hours or just that?
AllHailJ
(J Gent)
July 28, 2021, 3:36pm
3
I use brute force and stupidity method.
- id: '1625852459827'
alias: Water Lawn with timing given in frontend
description: Water All 11 irrigation zones based on the times set in the front end
trigger:
- platform: time
at: 04:00:00
- platform: time
at: 05:00:00
- platform: time
at: 06:00:00
- platform: time
at: '20:00:00'
- platform: time
at: '21:00:00'
condition:
- condition: state
entity_id: sensor.watering_days
state: '0'
action:
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_1
domain: switch
- delay: '{{ states(''input_number.zone1'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_1
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_2
domain: switch
- delay: '{{ states(''input_number.zone2'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_2
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_3
domain: switch
- delay: '{{ states(''input_number.zone3'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_3
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_4
domain: switch
- delay: '{{ states(''input_number.zone4'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_4
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_5
domain: switch
- delay: '{{ states(''input_number.zone5'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_5
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_6
domain: switch
- delay: '{{ states(''input_number.zone6'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_6
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_7
domain: switch
- delay: '{{ states(''input_number.zone7'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_7
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_8
domain: switch
- delay: '{{ states(''input_number.zone8'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_8
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_9
domain: switch
- delay: '{{ states(''input_number.zone9'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_9
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_10
domain: switch
- delay: '{{ states(''input_number.zone10'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_10
domain: switch
- type: turn_on
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_11
domain: switch
- delay: '{{ states(''input_number.zone11'') | multiply(60) | int }}'
- type: turn_off
device_id: 38223fea48e33bd0c222d08f40769e3e
entity_id: switch.zone_11
domain: switch
mode: single
The key is the delay. I use an input time because it is watering my lawn but the concept is the same. The delay can cause problems if the system reboots during the automation.
Edit: I should note that I use garbage collection from HACS to set the watering day. This is an easy integration to setup and it works for lots of things.
Here is the cleaned setup from my configuration.yaml
#
# Use garbage collection to set events and holidays
#
garbage_collection:
sensors:
- name: Clean day
frequency: even-weeks
collection_days: thu
- name: birthday
frequency: annual
date: '01/20'
- name: birthday1
frequency: annual
date: '01/20'
- name: birthday2
frequency: annual
date: '01/20'
- name: Anniversary
frequency: annual
date: '01/20'
- name: birthday4
frequency: annual
date: '01/20'
- name: New Years Day
frequency: annual
date: '01/01'
- name: Valentines
frequency: annual
date: '02/14'
- name: Presidents Day
frequency: "monthly"
collection_days: "mon"
weekday_order_number: 3
period: 12
first_month: "feb"
last_month: "feb"
- name: Memorial Day
frequency: "monthly"
collection_days: "mon"
weekday_order_number: 5
period: 12
first_month: "may"
last_month: "may"
- name: Juneteenth
frequency: annual
date: '06/19'
- name: Independence Day
frequency: annual
date: '07/04'
- name: Labor Day
frequency: "monthly"
collection_days: "mon"
weekday_order_number: 1
period: 12
first_month: "sep"
last_month: "sep"
- name: Halloween
frequency: annual
date: '10/31'
- name: DiadelosAngelitos
frequency: annual
date: '11/01'
- name: DíadelosDifuntos
frequency: annual
date: '11/02'
- name: DíadelosMuertos
frequency: annual
date: '11/02'
- name: Veterans Day
frequency: annual
date: '11/11'
- name: Thanksgiving
frequency: "monthly"
collection_days: "thu"
weekday_order_number: 4
period: 12
first_month: "nov"
last_month: "nov"
- name: Christmas
frequency: annual
date: '12/25'
- name: Boxing Day
frequency: annual
date: '12/26'
- name: Watering Days #summer months
frequency: "weekly"
collection_days:
- tue
- thu
- sun
first_month: "apr"
last_month: "oct"
1 Like
123
(Taras)
July 28, 2021, 4:00pm
4
This is a script that repeats the desired sequence of on/off commands 3 times:
alias: Sprinkler
sequence:
- repeat:
count: '3'
sequence:
- service: switch.turn_on
target:
entity_id: switch.sprinkler
- delay: '00:10:00'
- service: switch.turn_off
target:
entity_id: switch.sprinkler
- delay: '00:20:00'
mode: single
For convenience, create a Button Card with a tap_action
to execute the script.
If you want to make an automation of it, use a State Trigger with an input_boolean.
alias: sprinkler Control
trigger:
- platform: state
entity_id: input_boolean.sprinkler_flush
to: 'on'
action:
- repeat:
count: '3'
sequence:
- service: switch.turn_on
target:
entity_id: switch.sprinkler
- delay: '00:10:00'
- service: switch.turn_off
target:
entity_id: switch.sprinkler
- delay: '00:20:00'
- service: input_boolean.turn_off
target:
entity_id: input_boolean.sprinkler_flush
mode: single
An enhanced version would include the ability to stop the repetitions if the input_boolean is manually turned off.
2 Likes
123
(Taras)
July 28, 2021, 4:11pm
5
If you’re interested, your automation can also use repeat
to perform the 11 repetitions.
- id: '1625852459827'
alias: Water Lawn with timing given in frontend
description: Water All 11 irrigation zones based on the times set in the front end
trigger:
- platform: time
at:
- '04:00:00'
- '05:00:00'
- '06:00:00'
- '20:00:00'
- '21:00:00'
condition:
- condition: state
entity_id: sensor.watering_days
state: '0'
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 }}'
1 Like
AllHailJ
(J Gent)
July 28, 2021, 4:15pm
6
Thank you for the solution. Still learning and using the UI to get things up and running.