Last active
October 1, 2023 22:16
-
-
Save Didgeridrew/8c251221b54c36dfb01fff8e04383819 to your computer and use it in GitHub Desktop.
HA - Use Calendar list service to define binary sensor and populate attribute.
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
| # 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'] }}" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/)