Cannot trigger automation based on calendar event

Hi …

While I have not used calendar triggered automatons before, I thought my use case is dead simple and would be easy, but here I am, cannot figure this out …

Basically, I maintain different calendars on iCloud for specific tasks … I have them integrated with HA using CalDAV, this part works - been using the integration for a while just to display my calendars and everything shows up as expected.

Now I am trying to create automations based on whether or not ANY event starts on a specific calendar … In my troubleshooting I simplified the yaml to just display a notification, this is what I have now :

alias: MAKE IT WORK
description: ""
triggers:
  - event: start
    offset: "0:0:0"
    entity_id: calendar.travel
    trigger: calendar
conditions: []
actions:
  - data:
      message: Detected a calendar event.
    action: notify.persistent_notification
mode: single

And this does not seem to work :frowning:

I created a test event and checked with the developer tools - the state does turn to on and I see my event:

Yet this automation never triggered … :frowning:

I am hoping I overlooked something very obvious, but the code above is literally adapted from the calendar events documentation, so I am feeling a bit lost :slight_smile: Any pointers and suggestions are much appreciated :slight_smile:

One possible cause is the update window. During normal operation, the listener for Calendar event triggers only updates every 15 minutes.

When testing, you need to account for this by setting the event’s start to at least 15 minutes in the future, or by forcing the listener to update by reloading the calendar and automation after you have created the test event.

Calendar - Automation (bottom of the section)

FWIW, I call the following script whenever I have an automation that creates calendar events that might fall into the 15 minute window:

Calendar/Automation Reload Script
alias: Reload Calendar & Automation
fields:
  calendars:
    name: Calendars
    description: ""
    required: true
    selector:
      entity:
        multiple: true
        filter:
          domain: calendar
  automations:
    name: Automations
    description: ""
    required: true
    selector:
      entity:
        multiple: true
        filter:
          domain: automation
sequence:
  - action: homeassistant.update_entity
    metadata: {}
    data:
      entity_id: "{{ calendars + automations }}"
  - repeat:
      for_each: "{{ calendars}}"
      sequence:
        - action: homeassistant.reload_config_entry
          metadata: {}
          data: {}
          target:
            entity_id: "{{ repeat.item }}"
  - action: homeassistant.update_entity
    metadata: {}
    data:
      entity_id: "{{ calendars + automations }}"
description: ""
icon: mdi:calendar-question-outline
1 Like

Oooh thanks for this, this might be it! I’ll test tonight… I thought I was going insane :laughing:

The script looks super useful, thank you for sharing it

I know the exact feeling…

Hallelujah this was it, thanks so much …

Sooo…. My automation was working the entire time just not for the tests events I was creating lol :laughing: I appreciate the help … and I’ll definitely be using your scripts for events I push to the calendar

1 Like