How to catch calendar events added in-medias-res

Hi,

How to catch a calendar event with an automation (trigger?) that gets added “now” with a start date of e.g. yesterday, end date with tomorrow.
Like event start is 2024-05-14, end date is 2024-05-20, now is 2024-05-16.
I’d like to do some action in this case. (Actions on event start work fine, can just happen that the event gets added later, but power shall be still switched on)

If there aren’t any other events that are currently active, the case you described would cause the calendar entitiy’s state to change from off to on which could be captured by a State trigger. You would need to filter out false positives that would happen whenever events start normally. This method would not work reliably for calendars that regularly have overlapping events.

Another option would be to have a trigger-based template sensor fire a few times every hour and return a count of events in the current hour block. Then your automation would trigger off the change of the template sensor. Again you would need to filter out false positives like that which would likely happen when the hour changes and if events are deleted.

Thank you!

That sounds good, then that trigger will handle event start too.

It will only do so reliably if the calendar never has overlapping events. Be aware that back-to-back All Day events act as overlapping events so they would fail to trigger as well. This was one of the main reason for creation of the Calendar Event trigger. The State trigger is not reliable in too many situations if you cannot guarantee that the calendar will not have concurrent events.