I’m trying to figure out how to make an automation based on a specifc event in the local calendar. Now it’s always the “next” event but I’m unable to specify which event it needs to trigger on. Is that possible?
Use a Calendar Trigger then use conditions to limit execution of the actions based on one of the attributes of the calendar event. While you can use State conditions to filter calendar triggers, there can be a few issues doing it that way. Best practice is to use Template conditions based on the trigger
variable.
alias: Notify on Calendar Event
description: ""
trigger:
- platform: calendar
event: start
entity_id: calendar.local
condition:
- condition: template
value_template: "{{ trigger.calendar_event.summary == 'My Event' }}"
action:
- service: notify.mobile_app
data:
message: "{{ trigger.calendar_event.summary }} is starting"
mode: parallel
EDIT: Modified condition to make it less confusing for new users.
hmm what is wrong with mine ? it dont trigger
alias: Lokal Kalender Husk
description: ""
trigger:
- platform: calendar
event: start
entity_id: calendar.lokal_kalender
condition:
- condition: state
entity_id: calendar.lokal_kalender
attribute: message
state: TEST - "{{ trigger.calendar_event.summary == 'TEST' }}"
action:
- service: notify.mobile_app_rhmobil
data:
message: Husk TEST
title: "Påmindelse:"
mode: parallel
The main issue is you haven’t formatted it properly. I have updated the example configuration above to reflect best practice and to be clearer for users unfamiliar with template conditions.
alias: Lokal Kalender Husk
description: ""
trigger:
- platform: calendar
event: start
entity_id: calendar.lokal_kalender
condition:
- condition: template
value_template: "{{ trigger.calendar_event.summary == 'TEST' }}"
action:
- service: notify.mobile_app_rhmobil
data:
message: Husk TEST
title: "Påmindelse:"
mode: parallel
Another possible source of failed triggering is that, in normal operation, calendars are only updated every 15 minutes. If you are testing calendar triggers you need to either set the calendar event at least 15 minutes in the future or set the event, then reload the automation.