Google calendar event based automation

I am slowly switching from Homey to Home Assistant because I have more possibilities with Home Assistant than with Homey.
Now I can create a flow in Homey in which I can create an automation based on an event.
So if event “TEST” is in the agenda, things will be turned on or off, for example.

I have looked here on the forum and found something with a template, but that does not work for me.

Can someone help me further to create such an automation?

Thanks.

1 Like

Share the automation you used and describe, specifically, what did not work for you. Please also describe the method you used to test your automation.

One of the most common causes of frustration with new users of the Google Calendar integration is the failure to understand the timing of the calendars get synced from Google’s servers.

When testing automations based on Calendar event triggers, keep in mind that the Calendar trigger listener only refreshes every 15 minutes.

When you modify the calendar, you’ll need to either:

  • Schedule your event after the next quarter hour.
  • Force the listener to refresh by saving/reloading the automation. This will likely require an edit to the automation to bring up the “Save” button.

If you don’t do one of the above, your test calendar event will happen but not trigger the automation.

This is my automation.

alias: Kalender TEST
description: ""
trigger:
  - platform: calendar
    entity_id: calendar.gezin
    event: start
    offset: "0:0:0"
  - platform: time
    at: "12:06:00"
condition:
  - condition: template
    value_template: "\"{{ trigger.calendar_event.summary == 'Werken' }}\""
action:
  - action: button.press
    metadata: {}
    data: {}
    target:
      entity_id: button.wake_nas
  - action: notify.mobile_app_telefoon_xxxx
    metadata: {}
    data:
      message: TEST
mode: single

This here is the cause of the condition failing. The outer quotes are not part of the template, but needed in the yaml file because a string cannot not start with {{ because it will be interpreted differently. This should work:

    value_template: "{{ trigger.calendar_event.summary == 'Werken' }}"

As a fellow former Homey user: Welcome. You won’t regret the switch once you get used to the miriad of languages, such as jinja2, yaml, javascript and whatnot :slight_smile: Fortunately, they are needed less and less due to the editor getting better.

1 Like

Thanks but unfortunately it still doesn’t work. When I test the template I get “Not met condition” translated from Dutch.
I have tested multiple events but keep getting the message that the condition is not met.

I have multiple calendars, could it have something to do with that?

Sorry, I stopped looking after the first error I spotted.

The time trigger will not work, because if the trigger is a time trigger then the event is not set in the trigger variable. The same goes for manual triggering. The condition will never work when testing from the button in the automation editor.

Then, the way you check in the condition, the summary should be an exact match, down to the capitals. Also make sure the text is in the summary. I confure the fields sometimes myself. And last but not least, the calendar does not get updated immediately if you add an entry to a calendar. It can take upto 15 mins before a new appointment is seen. So prepare to take some time for your test :slight_smile:

If you really want a time trigger, you need to test differently. Then you should check the state and attributes of the calendar entity, not the trigger variable. The easiest way to implement that might not work if there are overlapping calendar entries in the same calendar.

I will put this on hold for now and will get back to it when I have more time for it.
Homey wins at this point :wink:

Thanks for now.

Ease, yes, feature wise, no. Overlapping with time trigger is possible too, just a bit harder.

I just automated intelligent car charging based on solar production prediction, car calendar and google travel time, using nothing but the base integrations. Does Homey have a decent dashboard yet? Homey can’t win. :wink:

1 Like

I have got this working now.

Thanks.

1 Like