Retrieve calendar events through templating

Hi all,

I’m quite new to Home Assistant but loving it so far and getting addicted.
I would like to set up an automation to wake me up 60 minutes before my first meeting of the day, which can vary depending on my work schedule.

I was looking at how to set up a template binary sensor to trigger, and and was going to use templating to try and get the first event of the day. However, it seems I cannot get events through the jinja templating. I seem to only be able to get the ‘current’ entry. I may be able to get this to work in my case, but it seems like quite a functionality gap to not be able to iterate over for example current day events. Is there any way?

I see that the frontend components query the API: api/calendars/<calendar.name>?start=...&end=...

I was expecting to be able to do something like (just as an example showing the point of iterating on events):

{% set starttime = null %}
{% for event in calendar.<name>.events %}
  {% if !starttime or event.start_time < starttime %}
    {% set starttime = event.start_time %}
  {% endif %}
{% endif %}
{{ starttime }}

Thanks in advance!

Any luck with this??

Afraid not. The calendar support in HA seems quite primitive. You only seem to be able to use the calendar as a sensor which is only the next event/appointment. Well, it depends on the integration providing the calendar actually. It provides the sensor(s). It’s a shame you can’t make your own outside of the integration supported configuration

My thought is to pull the ics file from the secret url for the google calendar parse it and publish to mqtt with 30 min sensors for 24 hours. Expand that for a week or month as necessary. For my intenets and purposes i just want my appointmnets for the day read to me in the morning.