Send an email with Calendar event

Hello Community

I am trying to automate event in calendar to send an email when an event start.
My Nextcloud calendar is available in HA and entities are present
I am referencing to the guide : Calendar

When I create the same context and execute it :

automation:
  - alias: Calendar notification
    trigger:
      - platform: calendar
        event: start
        entity_id: calendar.personel
    action:
      - service: persistent_notification.create
        data:
          message: >-
            Event {{ trigger.calendar_event.summary }} @
            {{ trigger.calendar_event.start }}

I receive this message : Error rendering data template: UndefinedError: ‘trigger’ is undefined

If i don’t use these template variables, the automation is running right

Is it something to modify or to add in the code to be able to use the trigger.calendar_event.summary and trigger.calendar_event.start template variables ?

How did you “execute it”?

If you tested it by using the automation’s Run command or by executing the automation.trigger service call, it will produce the error you received.

The trigger variable only exists if the automation’s Calendar Trigger is responsible for triggering the automation. The Run command doesn’t exercise an automation’s triggers, it only executes the automation’s action, so in that situation the trigger variable is undefined.

By “execute it” do you mean that you are manually triggering the automation using the “Run” button? Manually triggering an automation does not create a trigger variable that can be referenced as you have in you notification. To test your automation you will need to create a test event in your calendar or wait for an existing event to start.

Exactly

you are right both, I was trying manually
it’s clearer now. I was wondering how the variable could exist

I am trying to run the automation automatically with an event
Thank for your quick help. I am going to confirm or not after my new attempt

1 Like

Great, it’s work like a charm
I have now a new girl friend from google who can speak to me each time a need a recall
:grinning_face_with_smiling_eyes: