Google Calendar: Get many events insgead of only next one

Hi all,

I implemented my Google Calendar into HA and it is working fine so far. I understood how to define calendars and how to search for specific stuff. However, it seems that the calendar sensor is always giving me back only the next appointment.

When using “get entities” in Node Red I can find mutliple entries, but only in different calendars.

I want rhasspy to read all my appointments for today in the morning - is that somehow possible? I think it should, as the Google calendar card is able to display me all appointments.

Hello,
as this is my first post/reply here, i’d like to say thank you for providing great home assistant.

I’m struggeling with the same problem, so the question is:
“How can i iterate over all upcoming appointments from Google calendar?”

I’ve successfully integrated google calendar and see all entries in lovelace and the entity is showing the next appointment. But i can’t find a way to iterate through a list of all appointments. Is there any way or do i need to write a python script to get a list of all appointments for the next day?

I’ve read the following docs and questions (just allowed two post two links):

Info on my setup:

Home Assistant OS
core-2022.3.8
Python-Version 3.9.9
Update-Channel: stable

Best greetings
Thorsten

There is a rest API that powers the UI that you can use to fetch all events within a particular time range.

Can you elaborate on what your use case is at a higher level? Would be helpful for understanding how people are intending to use calendar.

Thanks for your reply @allenporter .
I’d like to have an automation sending me an email every evening with a list of “all” calendar entries of the next day.

Example of email body:

Here's a list of all appointments for tomorrow:

- Complete Day: Event 1
- Complete Day: Event 2
- 10:30: Appointment 1
- 13:15: Appointment 2
- 20:15 Appointment 3
...

I want to find out if the next day contains an event with a special name (i.e. Frühdienst if my wife has early shift) so I can activate stuff based on that info (i.e. activate the early shift mode what is done manually now - to power on light and heat earlier).

Possible but not fun. You can iterate through; eg below

Will read through that.

Its irritating as HA can list me all events in lovelace so they have to be stored somewhere. Would be cool if I could access those data easily…

Whelp… …don’t read my post then! Iterating through events based off timestamps = :dizzy_face:

Will check it anyways :wink:

Hi,

When doing something like this, one observation is that you really have two different things you need here: (1) Is there an event with a specific time in a specific range (2) have a trigger to power on the light/heat, or send a notification, etc.

Here is an example for how you can have a sensor that tells you if you need to take out the trash for pickup tomorrow:

template:
- trigger:
   - platform: calendar
     event: start
     entity_id: calendar.device_automation_schedules
     offset: "-24:00:00"
   - platform: calendar
     event: end
     entity_id: calendar.device_automation_schedules
     offset: "-24:00:00"
 binary_sensor:
   - name: trash_pickup_tomorrow
     state: "{{ iif('Trash Pickup' in trigger.calendar_event.summary, iif(trigger.event == 'start', 'on', 'off'), states('binary_sensor.trash_pickup_tomorrow')) }}"

This works simply for an all day event. The trick is that sets the state to on 24-hours before the event starts and off 24-hours when the event ends but also ignores other events that don’t match.

So imagine instead we’re making an “early_shift” binary sensors template. It sounds a bit more complex since the offset logic is a little different. It’s almost like you’d have to add multiple different event start triggers (e.g. one per hour) based on event start, maybe turn off logic is simpler.

Then imagine you want some other schedule to trigger when the early shift is supposed to start e.g. have a Time trigger at 3am, check the condition if early shift sensor is set, then run the action to turn on the heat.

I just started a discussion with other core developers about how to best serve these more complex calendar use cases even easier and simply via Ui streamlining, but no big breakthroughs yet, but this is really helpful to talk through for understanding more use cases.

2 Likes

I will give this a try as soon as I find the time, thank you!