Calendar notification triggers message only for first event

Hello everyone,

I’m new to this forum and hope I’m posting in the right section, seeking advice or guidance. If this is not the correct place, please accept my sincerest apologies and direct me to the appropriate section.

Here’s my issue:

I have successfully installed an instance of Home Assistant (HAS) on my Raspberry Pi and configured it with Google Calendar. So far, everything has been running smoothly. When I add an event to my Google Calendar, it syncs with HAS, displaying all events just as I entered them. Additionally, I’ve integrated Telegram and generated a bot, which is configured in the config.yaml file as a notifier. I set up an automation that triggers 15 minutes before an event is scheduled to start. This automation sends a notification through the bot to my phone via Telegram. The configuration is as follows:

alias: Calendar Trigger
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "-0:15:0"
    entity_id: <MY_CALENDAR>
condition: []
action:
  - service: notify.<MY_NOTIFICATION_NAME>
    data:
      message: >
        Here’s an event coming up.

        Event: {{state_attr('calendar.<MY_CALENDAR>', 'message') }}

        Notes: {{state_attr('<MY_CALENDAR>', 'description')}}
      data:
        type: tts
mode: single

However, I’m encountering a problem. Everything functions correctly until the automation triggers for the first time. The automation sends a Telegram message with the first event’s notes and title. But, if the automation triggers again, the bot repeats the message from the first event in the calendar. This issue is particularly pronounced if I have a full-day events in my calendar - it gets stuck looping over the full-day event instead of sending messages for each event as they appear in the calendar, sorted by time. Any assistance or guidance would be highly appreciated.

As shown in the Calendar Automation examples, you need to use the trigger variable not the state object.

  - service: notify.<MY_NOTIFICATION_NAME>
    data:
      message: >
        Here’s an event coming up.
        Event: {{trigger.calendar_event.summary}}
        Notes: {{trigger.calendar_event.description}}
      data:
        type: tts

Thank you, @Didgeridrew. Your guidance led me in the right direction. The events are now cycling through seamlessly, and the Telegram notifications are neatly formatted, informing me accurately about the event name and description.

For anyone encountering the same problem, here is the complete solution once more:

alias: Calendar Trigger
trigger:
  - platform: calendar
    event: start
    offset: "-0:15:0"
    entity_id: <MY_CALENDAR>
condition: []
action:
  - service: notify.<MY_NOTIFICATION_NAME>
    data:
      message: |
        Here’s an event coming up.

        Event: {{ trigger.calendar_event.summary }}

        Notes: {{ trigger.calendar_event.description }}