Is it possible to know the name of the calling automation / script?

I suspect the answer is “no” but I asked this question about 3.5 years ago and it elicited no responses so I thought it was reasonable to ask again given how much has changed in HA over that time.

Depends on what you are asking, under Devices you can find in which automations these are used

Fair point…

I’d like my scripts to know what script or automation initiated it.
It is just for my own internal error and process logging so not a huge deal (hence 3.5 years since I first asked :wink: ) if it isn’t possible but it would be nice.

This is probably your best bet.

You can send a parameter (e.g. script_called_by) to your script:
action: call-service
service: script.sub_menuauswahl
script_called_by: xxx_any_name_you_like_xxx

In the called script you can acces the data:
alias: sub - Menüauswahl
description: Script who calls me
example: any script name

  • service: input_text.set_value
    value: “{{ script_called_by }}”
    entity_id: input_text.ausgewahlter_menupunkt
    mode: single
    icon: mdi:arrow-decision

Yeah, that’s pretty much what what I ended up doing, but using this…

script_called_by: >
  {{ this.entity_id }}

…which is the same every time so takes slightly less thinking effort :wink:

1 Like