MontyRisk
(Monty Risk)
September 3, 2021, 8:21am
1
Hi,
For my vacuums, I have scripts for specific rooms.
On Tuesday, I want to vacuum the whole downstairs, on Saturday just want to vacuum the bedroom. Can I have 1 automation, but select script to run based on the day of the week?
- alias: Vacuum Downstairs
trigger:
platform: time
at: '08:30'
condition:
- condition: time
weekday:
- tue
- sat
action:
- service: script.vacuum_downstairs
Try using this-
trigger:
- platform: time
at: '08:00'
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: >-
{{ now().isoweekday() == 2 }}
sequence:
- service: script.turn_on
target:
entity_id: script.abc
- conditions:
- condition: template
value_template: >-
{{ now().isoweekday() == 6 }}
sequence:
- service: script.turn_on
target:
entity_id: script.xyz
default: []
It is using Choose Action with a template condition to check the weekday.
Another alternative that only trigger on specific condition-
trigger:
- platform: template
value_template: '{{ now().isoweekday() == 2 and (now().hour,now()minute) == (8,30) }}'
id: Tuesday
- platform: template
value_template: '{{ now().isoweekday() == 6 and (now().hour,now()minute) == (8,30) }}'
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Tuesday
sequence:
- service: script.turn_on
target:
entity_id: script.abc
default:
- service: script.turn_on
target:
entity_id: script.xyz
Additional note: weeks start with Monday and end on Sunday.
MontyRisk
(Monty Risk)
September 3, 2021, 10:16am
3
Thank you very much! I remember reading about this but never practiced it. This will remove several separate automations.