Automation / Calendar / Condition .. is this even possible

I’m having an automation including several triggers. What I’d like to add in conditions is a condition from calendar.
If possible, I believe there should be a template similar like this:

{{is_state “(‘calendar.kalender.summary’ ‘Urlaub’)}}”

this should return true or false depended if there is a holiday or not. Quite clear the above is not working. Anyone has an idea if this is even possible? If yes, how to do.

Thanks.

Again, just to be clear this must be a conditon not a trigger

If you have a calendar whose contents are only all-day events marking out all holidays, you should be able to simply check whether the state of that calendar is “on”.

- condition: state
  entity_id: calendar.holidays
  state: "on"

Or if you prefer a template:

- "{{ is_state('calendar.holidays', 'on') }}"

If the same calendar can contain non-holiday events as well I don’t think it is possible to do with only a trigger and/or condition. As I recall the attributes on the calendar itself only shows the properties of the current event (or if no event is currently occurring, the next upcoming event), so if you had another all-day event or a timed event overlapping with your holiday, there is no reliable way to always detect the holiday only using attributes.

You would need to use a calendar.get_events action and iterate through the results. Probably the best approach here would be a separate automation that ran every day at midnight, iterated through the next day’s events to see whether they contain a holiday or not, then toggles the status of an input_boolean helper to be used as a condition of your other automation(s).

I think you’ll need to create a template binary sensor helper and turn this on or off with a calendar trigger (or do it all in one with a YAML trigger-based template binary sensor) using the trigger data to check if it’s a holiday event.

Then use the state of that binary sensor as a condition in your main automation.

Wow, thank you @Mayhem_SWE and @Troon for your immediate help. As I’m fairly new to HASS I’ll continoue with the first approach this is really simply, althouth I understand the limitions.
When I get more advanced :wink: I’ll certainly implement the helper approach.

Thank you both.

There’s also this:

although you have to tell it any holidays that are additional to weekends / national holidays.

That gives you a binary sensor that you can use in a condition.

1 Like