Help: Use variable for 'notify.mobile_app_xxx' possible?

I have a simple notification script where I would like to replace the according static code part by a variable, which would make it possible to notify dynamically the according script-calling device.

So instead of this:
notify.mobile_app_myPhone

Something like this:
"notify.mobile_app_{{myPhone}}"

Would that be possible? If so, what would the variable {{myPhone}} look like?
Thank you!

I don’t understand your question. are you asking how you’d pass it to your script?

I see I should have been more clear.
Let me try again to explain:

My script now look like this:

action: notify.mobile_app_myDevice
metadata: {}
data:
  message: FooBar

But I would like to have it like this:

action: notify.mobile_app_{{variable}}
metadata: {}
data:
  message: FooBar

The idea behind this is I would like the script to send the according message to the device that has called the script originally.

So if I call the script with my device, the notification message should appear on my device.
If my wife calls the script with ther device, the notification message should appear on her device.
If one of my kids calls the script with its device, the notification message should appear on its device.

How will your device (or anyone else’s) call the script?

Is it from an automation that is triggered by some event (like which person arrives home) that then calls the script. Or merely from a Button card?

Knowing how you intend to call the script will help us answer your original question

This is what I’m asking @popcornboy

If im understanding you correctly then youd like your script to automatically pick the correct mobile device based on who called the script?

If so you can use context to do what you want.

You will have to convert the context.user_id to the correct action as i dont think the user_id is the same as the action. As others have said that would also depend how the script is been called.

Exactly.

Your suggestion to use context requires the script to be called by an automation (context is a property of the trigger variable).

Ok, I was not aware that the answer is dependent on how the script is being called, apologies.
The script is being called by double tapping an according card as follows:

type: horizontal-stack
cards:
  - type: custom:mushroom-template-card
    primary: ""
    secondary: ""
    icon: mdi:lock-question
    icon_color: ""
    layout: vertical
    tap_action:
      action: none
    hold_action:
      action: none
    double_tap_action:
      action: perform-action
      target:
        device_id: []
        area_id: []
        entity_id: script.notifyaboutopendoorandwindowsensors
      perform_action: script.turn_on
      data: {}
grid_options:
  columns: 12
  rows: 1

And are you expecting that it to know who did the double tap or are you going to pass that variable to the script?

Yes, I’d expect it to now which device did the double tap. Not going to pass any value to the script.

ok, then it’s not a variable, which is why most of us are confused. In order to make a proper template, we need to see your actual mobile id because you have to link user to person to assigned device tracker, then extrapolate the device tracker object_id for use in the notify service.

Right I can see the point of it not being a variable when I do not pass any values to the script, lesson learnt on how to be more precise, thanks for the hint!

Well currently I have the following three mobile IDs (assuming you mean the device names in HA):

  • 8t
  • fp3
  • fp5