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?
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.
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.
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.
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…
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!