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:
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).
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 I’ll certainly implement the helper approach.