Use any calendar you want to turn entities on and off, run scripts or start timers.
If an entity ID is found in the title or description of a calendar event, it will be turned on when the event starts and turned off when the event ends. Scripts, scenes and timers are supported too, they are started but not stopped.
blueprint:
name: Turn entities on or off using a calendar
description: Use any calendar to turn entities on and off, run scripts of start
timers. If an entity ID is found in the title or description of a calendar event,
it will be turned on when the event starts and turned off when the event ends.
Scripts, scenes and timers are supported too, they are started but not stopped.
domain: automation
input:
entities_calendar:
name: Calendar whose events are monitored for entity ID's
selector:
entity:
filter:
- domain:
- calendar
multiple: false
reorder: false
source_url: https://community.home-assistant.io/t/turn-entities-on-or-off-using-a-calendar-event/1032307
mode: queued
triggers:
- trigger: calendar
id: start
event: start
entity_id: !input entities_calendar
- trigger: calendar
id: end
event: end
entity_id: !input entities_calendar
variables:
ent_ids: >-
{{ ((trigger.calendar_event.summary ~ ' ' ~ trigger.calendar_event.description)
| replace('"',' ') | replace('=',' ') | replace('/',' ') | replace('\\',' ')
| replace(',',' ') | replace(';',' ') | replace(':',' ') | replace('\'',' ')
| replace('(',' ') | replace(')',' ') | replace('[',' ') | replace(']',' ')
| replace('+',' ') | replace('{',' ') | replace('}',' ') | replace('-',' ')
| replace('|',' ')).split() | select('search','^[a-zA-Z0-9_]+\\.[a-zA-Z0-9_]+$') | list }}
turn_on_ent_ids: >-
{{ ent_ids | reject('search','^timer\\.') | list }}
timer_ent_ids: >-
{{ ent_ids | select('search','^timer\\.[a-zA-Z0-9_]+$') | list }}
turn_off_ent_ids: >-
{{ ent_ids | reject('search','^script\\.|^timer\\.|^scene\\.') | list }}
turn_on: >-
{{ trigger.id == 'start' and turn_on_ent_ids is list and turn_on_ent_ids | length > 0 }}
timer_start: >-
{{ trigger.id == 'start' and timer_ent_ids is list and timer_ent_ids | length > 0 }}
turn_off: >-
{{ trigger.id == 'end' and turn_off_ent_ids is list and turn_off_ent_ids | length > 0 }}
conditions:
- condition: template
value_template: "{{ turn_on or timer_start or turn_off }}"
actions:
- if:
- condition: template
value_template: "{{ turn_on }}"
then:
- continue_on_error: true
action: homeassistant.turn_on
data: {}
target:
entity_id: "{{ turn_on_ent_ids }}"
- if:
- condition: template
value_template: "{{ timer_start }}"
then:
- continue_on_error: true
action: timer.start
data: {}
target:
entity_id: "{{ timer_ent_ids }}"
- if:
- condition: template
value_template: "{{ turn_off }}"
then:
- continue_on_error: true
action: homeassistant.turn_off
data: {}
target:
entity_id: "{{ turn_off_ent_ids }}"