Hi Everyone,
I’ll try to keep this short. I’ve done extensive research on this topic on this forum as well as others and cant seem to find anyone with the same issue as me. I’ll keep it simple, My built-in calendar events simply trigger when they feel like it. I’ll include an example. I have an event that is set to trigger every Sunday at 4pm for the past 6 months, sometimes it triggers sometimes it just doesn’t. I can view this by looking at the logbook. This issue is making me tear my hair out because with an inconsistent calendar, time-based automation is pretty much worthless.
Here is a combined photo since I’m only allowed to post one media item.
The top of the photo is of my Calendar events which I have not touched the config of for over 2 months They’re clearly supposed to trigger every Sunday.
the Bottom is my logbook:
Only triggered twice this month despite there being 3 Sundays this month.
It also triggered like once in April.
Anyone else experience this? Any solution i can try?
If you’re having an issue with an automation, please post the automation and any debug traces of failed runs. A calendar
entity’s state should almost never be used as a trigger. The Logbook will not show a “turn on” event if the calendar state stays “on” due to abutting or overlapping events.
That’s not what I said. The calendar entity’s state and calendar events are related, but they are not the same thing.
It looks like the calendar turned ‘on’ and ‘off’ as expected on both Sundays… The Logbook is limited to the duration of the Recorder’s purge cycle. The default purge is 10 days. May 5th was more than 10 days prior and May 26th hasn’t happened yet… so the Logbook shown seems to be working normally.
I see, i didn’t know the logbook had a 10 day limit on it.
So then how do I use a Calendar Event to trigger an automation without monitoring the Calendar state then checking the message. That’s how all the guides online I saw showed it done.
Is this automation YAML doing it in a bad way?
alias: PD HVAC ON
description: ""
trigger:
- platform: calendar
event: start
offset: "0:0:0"
entity_id: calendar.hvac_calendar
condition:
- condition: state
entity_id: calendar.hvac_calendar
attribute: message
state: AC Units On
action:
- device_id: 8d161f1420478ca8add221d4a9606ead
domain: climate
entity_id: climate.t6_pro_z_wave_programmable_thermostat_3
type: set_hvac_mode
hvac_mode: cool
mode: single
The unreliable method would be to use a State trigger.
What you have shown is the correct way to trigger, since it is using a Calendar Event trigger. Though I would caution against using a State condition as you have. It will work in your example case with a strictly controlled calendar, but it will introduce the same reliability issues if you have overlapping events. The better method is to use template conditions:
alias: PD HVAC ON
description: ""
trigger:
- platform: calendar
event: start
offset: "0:0:0"
entity_id: calendar.hvac_calendar
condition:
- condition: template
value_template: "{{ trigger.calendar_event.summary == 'AC Units On' }}"
action:
- device_id: 8d161f1420478ca8add221d4a9606ead
domain: climate
entity_id: climate.t6_pro_z_wave_programmable_thermostat_3
type: set_hvac_mode
hvac_mode: cool
mode: single
You may want to read over the Events and State objects docs if you are not familiar with how HA uses these core objects.
Thanks for this, Reading over what you linked and using some of the script you posted has fixed my Calendar Automations.