Problem with automation using calendar trigger

Hi all,

I have a problem with my automation. I keep getting the following error:

Error: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘calendar_event’

My automation YAML looks like this:

id: '123'
alias: Water plants
description: ''
trigger:
  - platform: calendar
    event: start
    offset: '0:0:0'
    entity_id: calendar.my_calendar
condition: []
action:
  - service: notify.mobile_app
    data:
      message: This is a {{ trigger.calendar_event.summary }}
      data:
        notification_icon: mdi:flower
mode: single

I already tried sending a notification without the {{ trigger.calendar_event.summary }} and it works without any problems.

Try looking at the calendar.my_calendar in developer tools / states and have a look if it has an summary

Hi Rossk,

Thank you for a quick response! I check and there are only two attributes: offset_reached and friendly_name. Do you know, by any chance how to add more attributes here? I tried searching for it, but I couldn’t find any walkthrough.

I got it to work! When I used this:

{{ states.calendar.my_calendar.attributes.message }}

it worked as it should. Thanks again for the help :wink:

Hi All,
I have a variant of this I can’t get to work.
The template {{ states.calendar.my_calendar.attributes.message }} works fine.

However I have multiple calendars, and I am trying to put together one automation that can be triggered by the a list of calendars, and perform the same action which is to get the message from which ever calendar triggered the event.

I have tried:

{{ this.attributes.message }}

as well as:

{{ states[this.entity_id].attributes.message }}

But I’m getting error logs:
'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'message'

Any suggestions?

[EDIT] I’ll add that I am using platform: calendar for the trigger.

After playing around some, I am still unsuccessful using the this variable. However I did get the following to work which does the same thing:

message: "{{ trigger.calendar_event.summary }}"