How can I get the ID of an automation and use it as a template variable?

I created a script that I use to send notifications via email, HA notification, and mobile. I then call this script from automation notifications, so that I do not need to repeat the boilerplate to call multiple services for alerting.

The script calls persistent_notification.create and requires the caller to pass in a variable that is used for notification_id. This allows each automation to have its own persisted notification where there is only one active at a time.

I’d like to avoid having to keep track of ID’s, and just use the ID of the automation itself.

E.g. something like this.id, or whatever the entity id of the script is called?

Is it possible to get the entity id as a template variable from within an automation?

E.g.

alias: "Notify: Solar Generation Low"
description: Send notification when solar generation is low
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.energy_production
    for:
      hours: 24
      minutes: 0
      seconds: 0
    below: 1000
condition: []
action:
  - service: script.notify_multiple_services
    data:
      identifier: "1005" <- Replace this with the auotmations' ID
      message: Solar Generation Low
      title: Solar
mode: single
      identifier: "{{ this.entity_id }}"

Thank you, wondering, is there a way to get the entity id of the caller of a script, that way I don’t need to pass in the identifier, I can just use the caller’s id?

I don’t think so. IIRC, it might be possible if you put your final actions in an automation instead of a script because of the additional context object data available to automations… but I might be completely mistaken on that or it may only work in certain situations since not all trigger types produce trigger context.