home-assistant / architecture

Repo to discuss Home Assistant architecture
317 stars 100 forks source link

Add list of (upcoming) calendar events to templating #805

Closed Olen closed 2 years ago

Olen commented 2 years ago

Context

There is currently no way to "loop through" calendar events in e.g a template for an automation or a script. You can access the current, or next upcoming, event directly in the calendar entity, but that is about it. There are API endpoints that will list events between dates, but there is no easy way to use these in a template.

Proposal

Add a function to the CalendarEntry or the state object so it would be possible to create something like

{% for event in calendar.my_calendar.get_events(from=timestamp, to=timestamp) %}
    ...
{% endfor %}

Consequences

Simple use cases are for instance a TTS notification that reads out loud all of todays calendar events in the morning, or an automation with a condition that an event with certain title is happening sometime in the next few days, without necessarily triggering the automation based on the time that event actually starts.

Olen commented 2 years ago

Moving to a discussion