Google calendar get events

Hey guys,

So I was wondering how I can retrieve google calendar events (time and name)

I want to make an automation inside node-red to check whenever my girlfriend has a night shift to set some action when shes in bed the next morning… at least prevent them shutters from going up when she’s in bed.
So If anyone has the template value laying around for retrieving those two values. please. when I try "

states.calendar.<calendar name>

It gives all values but I can’t seem to filter the values out.

Thanks!

1 Like

Is there anyone who knows this?

Are you using the Google calendar integration (https://www.home-assistant.io/integrations/calendar.google/)?

1 Like

Yeah. I have read the docs multiple times… I feel so retarded now.

trigger:
  platform: state
  entity_id: calendar.calendar_name
  to: 'on'
condition:
    condition: template
    value_template: "{{is_state_attr('calendar.calendar_name', 'message', 'vacation') }}"

Thanks!

1 Like

No problem! :smiley:

Hi, how can I possibly create a template sensor based on the calendar status “on” or “off” to display an event message??

You shouldn’t have to. The state already does that. What are you trying to accomplish with a template sensor?

image

A sensor that it will display a message “calendar event” for the current day as a state label for example

Literally the example I posted achieves that.

Your code is based on conditions, but how to change so it will display any event ?

Ok, so I have created a sensor

sensor 11:
  - platform: template
    sensors:
      cal_day:
        friendly_name: "Today's Event"
        value_template: "{{ state_attr('calendar.xxxxx_gmail_com', 'message') }}"

It works, thanks

1 Like

Hi, very late to the party, but what of you want to display multiple events?
I have a TV shows calendar that I want to be able to list the upcoming shows from.

Likewise.
Just added the Google Calendar integration & wanted to make a days until template for a specific event. Not finding how to see events beyond the next one - like the HA Calendar displays.

You can make a template with a trigger for a specific event but there is not really an easy way to search. The rest API can scan over a range, if you are comfortable with JavaScript and frontend ui cards.

Hi, this thread did end somehow before getting to the solution :slight_smile:
So, how could I achieve the following:

we have a Family calendar (google calendar), it is already integrated in Home Assistant.
There are multiple entries (all_day true and also all_day: false). I want be get a trigger if a specific full day event is three days ahead. I could not find a way to do that. If there are multiple full days events the routine only triggers if it’s the first event in the row. So sometimes I don’t get a trigger.

I know it sounds complicated, and maybe there is a easy solution? I would love to accomplish this within Node Red if possible.

(I know there would be a workaround for this: having a dedicated calendarf for these specific events, but this could cause our family to mix up entries and if unintentionally the specific event is added to thw wrong calendar, the family won’t see this in Home Assistant).

Hope someone can help?

best regards
TurboKanne

Within automations there is not an API for scanning events. The API the frontend uses is the rest API which can let you return events for a date range: REST API | Home Assistant Developer Docs – however, this is not typically how people get data from home assistant in an automation. I’ve been thinking about how to build this capability into home assistant more directly, but we don’t have a solution yet.

For Google, CalDav, and Baikal you can use the Hass Calendar Addon to create a sensor that makes the data from more calendar events available.

UPDATE:

With the addition of dedicated services like calendar.get_events and service response data, the Hass Calendar Add-on is no longer needed for most users.