Calendar Trigger not working

I have created an automation which should trigger based on a calendar event starting (with an offset). The calendar is not linked to anything external like google.

I’m using this for my garbage collection using the popular HACs integration however I just can’t get the automation to run. I have double checked the start time of the next event in the calendar via developer tools. What else am I missing here?

2 Likes

Can you give more details about what you’re doing, the automation, and what’s not working?

Here is the yaml from the automation:

alias: Bin Collection notification
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "-5:0:0"
    entity_id: calendar.garbage_collection
condition: []
action:
  - if:
      - condition: state
        entity_id: sensor.recycling_collection
        state: tomorrow
    then:
      - service: notify.mobile_app_iphone
        data:
          message: Recycling day tomorrow
  - if:
      - condition: state
        entity_id: sensor.rubbish_collection
        state: tomorrow
    then:
      - service: notify.mobile_app_iphone
        data:
          message: Rubbish day tomorrow
mode: single

It should trigger when the next event is scheduled to start in the calendar -5 hours but it never triggers. The idea is that it send me a notification to but the bin out the night before collection day.

One thing to check is the timezone of the calendar in gcal. Is it different than home assistant? There may be a bug here.

I can send instructions to enable debugging later.

Try it with your offset formatted in “H:MM:SS” notation.

trigger:
  - platform: calendar
    event: start
    offset: "-5:00:00"
    entity_id: calendar.garbage_collection
1 Like

This is a discussion about how to debug an issue like this: Offset with calendar integration is not triggering actions · Issue #74964 · home-assistant/core · GitHub – and shows which things we’d want to turn up debug logs for.

You can try without the offset if that helps diagnose the issue. The helpful bit is seeing the API server responses and comparing.

I don’t think timezone is the issue because I’m not using gcal. I’ve tried with the offset formatted H:MM:SS but it still didn’t trigger.

I’ve never looked at debugging before. Please could you provide steps to set this up?

I think this issue might be down to a bug. I found a post with the same issue here: Calendar automation with offset before calendar event does not work (but one with offset afterwards does)

I was able to get the automation to run with Event End and then setting the Before offset to 1 day and 5 hours.

I had the same issue. Try -hh:mm:ss instead of -h:mm:ss.

However, when you do it from the UI, it uses this format -h:m:s… so… the bug might be there.

1 Like

Could not get to work from the UI but yaml with “-01:00:00” works for Before. I think the UI is also setting the minus sign if After is selected, and not if Before is selected.

The type of trigger being used I could never get to work consistently. my solution was to change the trigger as follows:

trigger:
  - platform: state
    entity_id:
      - calendar.garbage_collection
    attribute: message

then I use a choose structure for the actions. for different scenarios based on the message.
Note that the message will automatically change to the next event in the calendar to overcome this I set in the calendar an event that I will not use such as “none” or “empty” to fill the time slots I have nothing scheduled. ideally the calendar message state should be set to null if nothing scheduled but this is not the case and requires the calendar addon code to be adjusted to accommodate that. I hope this helps since if started using message as the trigger I have not had any missed events.

Hey guys, I’m having a similar issue where I can’t get a calendar event trigger to run. Here’s my code:

alias: Pending Ohm Hour
description: Ohm Hour Pending Flag
trigger:
  - platform: calendar
    event: start
    offset: "-0:05:00"
    entity_id: calendar.family
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.ohmhour_pending
mode: single

The GUI set the offset to “-0:5:0”, I also tried manually setting it to “-00:05:00” and the one that’s displayed above.

I can’t even get this automation to fire without an offset? Not sure how to troubleshoot this? I confirmed the event is showing up on the calendar entity.

How are you testing?

IIRC, the Calendar trigger listener only refreshes every 15 minutes so you’ll need to reload the automation to pull in the recent data if you modify the calendar, or schedule test events for a minimum of 15 minutes in the future (20 minutes in your case with a -5 min offset) and wait…

How do I reload the automation?

I was reloading the google calendar integration to pull in the calendar events. I then would reload my calendar to confirm it was showing and it was. Is there 1 more service I needed to restart? That may be my culprit if so.

IIRC, they recently changed the behavior when using Dev Tools > YAML to reload automations so that only one’s that have changed are reloaded. So, your options are either to make a small change in the automation and save it (which initiates a reload of that automation) or perform a Restart of HA.

You were correct, it worked if I had the event scheduled in advance. There is probably a 15min delay like you were saying. Even my condition worked with a trigger word in the name. Thanks for your help!

1 Like