Automation based on Google Calendar

Hello

I’m trying to pre-condition my wifes car automatically if the Google Calendar has an event that says she has work. It should run 20 minutes before the shift starts.

I’ve tried creating this automation just to get anything to trigger of the work event “JBM Vagt” is in the calendar:

- id: '1645084866659'
  alias: Test Calendar
  description: ''
  trigger:
  - platform: state
    entity_id: xx_gmail_com
    attribute: message
    to: JBM Vagt
  condition:
  - condition: state
    entity_id: person.josefine
    state: home
  - condition: state
    entity_id: device_tracker.escape_pod_1_location_tracker
    state: home
  action:
  - device_id: ff5578aca08bdc5d61c5a89dc850aac8
    domain: mobile_app
    type: notify
    message: Josefine skal på arbejde.
  mode: single

This does not trigger even tho the event is present.

The sensor looks like this:

- cal_id: [email protected]
  entities:
  - device_id: xx_gmail_com
    ignore_availability: true
    name: Familie
    track: true

The event looks like this in the calendar:
Skærmbillede 2022-03-05 101628

Any ideas?
Thanks!

Trying changing to:

trigger:
  - platform: state
    entity_id: xx_gmail_com
    attribute: message
    to: JBM vagt

It’s case sensitive

Thank you.
It did not solve the problem however. The automation did not run.
Any ideas?

The documentation shows trigger as:

trigger:
  platform: state
  entity_id: calendar.calendar_name
  to: "on"

Then a condition of:

condition:
  - condition: state
    entity_id: calendar.calendar_name
    state: vacation
    attribute: message

What does the state of the entity show in dev tools?

Yeah i don’t understand the docs regarding the calendar at all.
It looks like this right now:

State:
on 	

Attributes:
message: MT Vagt
all_day: true
start_time: 2022-02-28 00:00:00
end_time: 2022-03-07 00:00:00
location: 
description: 
offset_reached: false
friendly_name: Familie

If i open the calendar today looks like this:
Skærmbillede 2022-03-05 101628

It looks to me that the all day event is going to cause your one calendar entity to be on all day and with the same message attribute.

You can set up as many calendar sensors as you want and this may be more beneficial.

For me I have regular recurring events so have set individual sensors for each of those.

But in any case the calendar can only have a state of on or off so this would be your trigger, but you can add the condition of the individual message, but maybe I guess not if you have an all day event with a different message

Okay i get what you are saying about the trigger and condition.

Could you elaborate on how to solve the issue with “all day” events being the message for the whole day?

Yeah, simply set up individual entities based on the calendar entries title.

Look at the documentation and see that you can setup as many sensors as you like for the same one calendar.

Take a look at Jeff Stone’s recent video… the key to making the Google calendar integration work with all day events is adding tags to messages and setting up a calendar sensor for each tag.