Automation conditions based on calendar items

Hey, I am using ics_calendar to import a calendar into HA. I’d like to trigger an automation to run several hours before the event starts, but only if the event name and the day of the week match my criteria.

How do I create the conditions to determine the event name and the day of the week of the event?

Thanks

Assuming you are using the Calendar event as your trigger, use the available trigger data for Calendar triggers in your conditions block.

You can search the event’s title using the search() function:

condition:
  - alias: Check event title for "My Search Term"
    condition: template
    value_template: |
      {{ trigger.calendar_event.summary is search('My Search Term') }}

There are a few ways to check the weekday of the event. One option is as follows:

  - alias: Check if event starts on a Tuesday
    condition: template
    value_template: |
      {{ (trigger.calendar_event.start |as_datetime).strftime('%A') == 'Tuesday' }}
1 Like