Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Last active October 1, 2023 22:16
Show Gist options
  • Select an option

  • Save Didgeridrew/8c251221b54c36dfb01fff8e04383819 to your computer and use it in GitHub Desktop.

Select an option

Save Didgeridrew/8c251221b54c36dfb01fff8e04383819 to your computer and use it in GitHub Desktop.
HA - Use Calendar list service to define binary sensor and populate attribute.
# Script
alias: Calendar 1-Day Agenda to Event
sequence:
- service: calendar.list_events
data:
duration:
hours: 24
minutes: 0
seconds: 0
target:
entity_id: calendar.my_calendar
response_variable: agenda
- event: custom_calendar_agenda
event_data:
calendar: my_calendar
cal_events: "{{ agenda }}"
mode: single
## Template binary sensor:
template:
- trigger:
- platform: event
event_type: custom_calendar_agenda
event_data:
calendar: my_calendar
binary_sensor:
- name: Calendar Agenda
unique_id: custom_calendar_agenda_001
state: "{{ trigger.event.data.cal_events['events'] | count > 0 }}"
attributes:
events: "{{ trigger.event.data.cal_events['events'] }}"
@patnodewf
Copy link

ok, so 1st part goes into scripts.yaml? where does the 2nd part go?

@Didgeridrew
Copy link
Author

It can go directly in configuration.yaml or any properly split file setup for the template integration (https://www.home-assistant.io/docs/configuration/splitting_configuration/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment