Last active
March 21, 2025 21:24
-
-
Save relvacode/e995b463e94c39bcbfbfdd007d921dbe to your computer and use it in GitHub Desktop.
Home Assistant Calendar Sync Blueprint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Calendar Sync | |
description: Create events in a calendar based on a date sensor | |
domain: automation | |
input: | |
sensor: | |
name: Date Sensor | |
description: The source date sensor | |
selector: | |
entity: | |
filter: | |
- domain: sensor | |
device_class: date | |
calendar: | |
name: Calendar | |
description: The calendar to create the event in | |
selector: | |
entity: | |
filter: | |
- domain: calendar | |
event_name: | |
name: Event Name | |
description: Set a specific name for the event. Use the sensor's friendly name if not provided | |
mode: single | |
max_exceeded: silent | |
variables: | |
input_sensor: !input sensor | |
input_calendar: !input calendar | |
input_event_name: !input event_name | |
trigger: | |
trigger: state | |
entity_id: !input sensor | |
action: | |
- action: calendar.get_events | |
target: | |
entity_id: !input calendar | |
data: | |
start_date_time: '{{ states(input_sensor) }}' | |
duration: | |
hours: 24 | |
minutes: 0 | |
seconds: 0 | |
response_variable: | |
existing_events | |
- condition: template | |
value_template: '{{ not existing_events[input_calendar].events | selectattr("summary", "eq", input_event_name or state_attr(input_sensor, "friendly_name")) | list }}' | |
- action: calendar.create_event | |
target: | |
entity_id: !input calendar | |
data: | |
summary: '{{ input_event_name or state_attr(input_sensor, "friendly_name") }}' | |
start_date: '{{ states(input_sensor) }}' | |
end_date: '{{ (states(input_sensor) | as_datetime + timedelta(days=1)).strftime("%Y-%m-%d") }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment