Google Calendar Event not triggered

What i whant is read the events in calendar and when the title is

something, for thi example ‘Test Calendario HA’, make an action,

I have Google Calendar installed and seem to work because the entity is active

and oneother card connected works, nut the automation never trigger the calendar event.

here the code


# Azione su Evento in Calendario Google
- alias: 'Pulizia Strada'
  trigger:
    platform: state
    entity_id: calendar.xxxxxxxxxxx_gmail_com
    to: 'on'
  condition:
    condition: template
    value_template: "{{is_state_attr('calendar.xxxxxxxxxxx_gmail_com', 'message', 'Test Calendario HA') }}"
  action:
    - service: script.applique_on  

I tried also without condiction

# Azione su Evento in Calendario Google
- alias: 'Pulizia Strada'
  trigger:
    platform: state
    entity_id: calendar.xxxxxxxxxxx_gmail_com
    to: 'on'
  action:
    - service: script.applique_on  

but it doesn’t work anyway! any Idea?

Thanks

At the time the event occurs, do you see “calendar.xxxx_gmail.com” changing state from “off” to “on”?
You can check on the sidebar -> Developer Tools -> States

Is always on because there is also a full day event

Then your automation can not work. The automation triggers when the calendar changes from “off” to “on”, if it is “on” all the time it will not trigger the automation.

OK

There is a way to detect a message without the status that change from OFF to ON ?

Yes there is, you can create a sensor for a specific event.
Can you please post your google calendar configuration? Then I should be able to help you set this up.

What do you mean for Google Calendar configuration?

I use Google Calendar API

and i follow this guide

One more think there is a complete guide ref for the home assistant script?

Very thanks

I mean the configuration for the calendar, probably in a file called “google_calendars.yaml” and looks something like this:

- cal_id: "*****@group.calendar.google.com"
  entities:
  - device_id: test_everything
    name: Give me everything
    track: true

I don’t understand this, what script are you talking about? The link you posted describes everything needed to setup google calendars and make automations with the events.


- cal_id: **************@group.calendar.google.com
  entities:
  - device_id: xxxx_xxxxxx_xxxxxx
    ignore_availability: true
    name: XXXXX XXXXXX (XXXXX)
    track: true

- cal_id: *********@gmail.com
  entities:
  - device_id: *********_gmail_com
    ignore_availability: true
    name: *********@gmail.com
    track: true

- cal_id: addressbook#[email protected]
  entities:
  - device_id: contacts
    ignore_availability: true
    name: Contacts
    track: true

- cal_id: it.italian#[email protected]
  entities:
  - device_id: festivita_in_italia
    ignore_availability: true
    name: "Festivit\xE0 in Italia"
    track: true

A general guide for every kind of script and automation

I assume that the second entry is the calendar which contains the event “Test Calendario HA”?

Add another section like this:

- cal_id: *********@gmail.com
  entities:
  - device_id: test_calendario_ha
    name: Test Calendario HA
    track: true
    search: "Test Calendario HA" # <-name of the event you want to track

This should create a sensor “sensor.test_calendario_ha” and this sensor will only change to “on” if the event has the name “Test Calendario HA”. You can then use this sensor as a trigger for your automation.

Regarding documentation:

1 Like

Very thanks for all your answer and for the time you are spending for me!

I done what you suggest and a new sensor has been created but the original one now return Response error: 400 and the new one is alwais not active!

Can you show the full config you have now for the calendar?
I think the calendar is only updating every 15 minutes, did you wait at least 15 minutes before you checked?
Maybe you need to add a # before the search term for it to work, I can’t verify as I don’t use google calendar myself. Like this:

- cal_id: *********@gmail.com
  entities:
  - device_id: test_calendario_ha
    name: Test Calendario HA
    track: true
    search: "#Test Calendario HA" # <-name of the event you want to track

WHat is the name of the language used for this script?

here the script, itseem that the last one go in conflict with the second one that are stopped to work

- cal_id: **************@group.calendar.google.com
  entities:
  - device_id: global_italia_giulio
    ignore_availability: true
    name: XXXXX XXXXXX (XXXXX)
    track: true

- cal_id: *********@gmail.com
  entities:
  - device_id: *********_gmail_com
    ignore_availability: true
    name: *********@gmail.com
    track: true

- cal_id: addressbook#[email protected]
  entities:
  - device_id: contacts
    ignore_availability: true
    name: Contacts
    track: true

- cal_id: *********@gmail.com
  entities:
  - device_id: pulizia_strada
    ignore_availability: true    
    name: Pulizia Strade
    search: "Domani Pulizia Strada"    
    track: true

It’s not a script, it’s a configuration. The language used is YAML.

Maybe you need to combine the second and the last entry like this

- cal_id: **************@group.calendar.google.com
  entities:
  - device_id: global_italia_giulio
    ignore_availability: true
    name: XXXXX XXXXXX (XXXXX)
    track: true

- cal_id: *********@gmail.com
  entities:
  - device_id: *********_gmail_com
    ignore_availability: true
    name: *********@gmail.com
    track: true
  - device_id: pulizia_strada
    ignore_availability: true    
    name: Pulizia Strade
    search: "Domani Pulizia Strada"    
    track: true

- cal_id: addressbook#[email protected]
  entities:
  - device_id: contacts
    ignore_availability: true
    name: Contacts
    track: true

now both calendar work but the second pulizia_strada is always not active… and stay always off :roll_eyes:

We are getting closer :stuck_out_tongue: You have now a sensor called “sensor.pulizia_strada” right?
And the event in your calendar is named “Domani Pulizia Strada” and at the time the event starts, the calendar stays off?
Can you try putting a # before “Domani Pulizia Strada”?

Yes with and without # but the problem i think is the pulizia_strada is disabled and i don’t know why!!
entity global_italia_giulio disabled
entity *********@gmail.com enabled and works
entity pulizia_strada disabled and doesn’t work
entity ddressbook#[email protected] disable
I don’t know why some calendar are disabled, until they are in this state i don’t think they can work
where i can enable them?

What do you mean with “they are disabled until they are in this state”, do you mean the state is “off” until the event starts and then turns to “on”, or is it “off” all the time?

OK ok ok

search: “Domani Pulizia Strada”

This finally work… a stupid error Strada-Strade but now is ok

Thank you very much!

I’m New, Last question is possible to set a general variable not boolean but numeric for example,

and change it with a button and read it in a condiction?

Thanks