How to test/debug Calendar automations?

I have added a local calendar with recurring events and followed the automation examples from Calendar - Home Assistant but I am not receiving any notifications. When I try to Run the automation I get the following error in the traces.

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

Here is my full automation YAML

alias: Calendar Notification
description: Send notification on Calendar Events
trigger:
  - platform: calendar
    event: start
    offset: "0:0:0"
    entity_id: calendar.default
condition: []
action:
  - service: notify.all_iphones
    data:
      title: Calendar Notification
      message: |-
        Event {{ trigger.calendar_event.summary }} @
            {{ trigger.calendar_event.start }}
mode: single

Any suggestions on what may be wrong?

You cannot test automations that rely on the trigger variable by using the “Run” button. Since there is no trigger, test running an automation that way does not place any values in the trigger variable.

To test a calendar-based automation you should create a test event that starts (or ends depending on your goal) a few minutes in the future, taking into account any offsets you have included in your trigger. Then reload the automation so that the trigger listener is created and the calendar is reloaded. Wait for your automation to fire.

Thanks, @Didgeridrew I will give this a go.

The Calendar trigger only refreshes every 15 minutes so you’ll need to reload the automation to pull in the recent data if you modify the calendar.

Hello. How to test template sensor now? I want to know if the below code is valid and will display tomorrow’s event. These events are populated from google calendar and not from local calendar.

template:
  - trigger:
      - platform: calendar
        event: start
        entity_id: calendar.holidays
        offset: "-24:00:00"
    sensor:
      - name: "Holidaytomorrow G"
        state: "{{ iif( 'Holidays' in trigger.calendar_event.summary, iif(trigger.calendar_event.message != '' ), states('sensor.holidaytomorrow_g' )) }}"

Your template will fail since your second iif

... iif(trigger.calendar_event.message != '' ) ....

has no values for “if-true” and “if-false”.

Once that is fixed, you can test Calendar event based template sensors by setting a test event at a time equal to your offset plus at least 15 minutes to allow for the calendar trigger listener to refresh… then wait for the trigger to fire.