mjanssen
(Martijn Janssen)
1
Hi,
I have a calendar that contains our holidays.
I’m trying to create two automations:
One that triggers when a holiday starts, but only if the holiday is longer than 48 hours
One that triggers 24 hours before the holiday ends.
I’m fairly new to HA, so any pointers are welcome
You can trigger off the start and/or end of a calendar event using a Calendar trigger. Then use the available trigger data as part of a condition.
If your holiday events are multi-day event you could use something like:
trigger:
- platform: calendar
entity_id: calendar.holidays
event: start
condition:
- alias: Holiday is at least 48 hours long
condition: template
value_template: |
{{ trigger.calendar_event.end|as_datetime|as_local - trigger.calendar_event.start|as_datetime|as_local >= timedelta(hours = 48) }}
24-hours before end:
trigger:
- platform: calendar
entity_id: calendar.holidays
event: end
offset: "-24:00:00"
mjanssen
(Martijn Janssen)
3
Thanks! Implemented. I’ll update in a couple of days if any adjusting is required.
mjanssen
(Martijn Janssen)
4
Quick update, bit later than a couple of days though
Everything works perfectly with the above implementation!