Get mobile_app id from mobile_app.share

Hello all!

I am working on an automation where the user of the mobile app (on Android) shares (for instance) a youtube link to the HomeAssistant app. Home Assistant triggers an automation based on mobile_app.share event. The automation should send back a notification only to the client which sent the share event (I have several clients), giving them a list of players where to play the URL being sent.

My problem is - how do I find out which mobile_app instance I need to send the notification to, based on the event data?

Here’s a sample event that I can see in Developer Tools → Events:

event_type: mobile_app.share
data:
  caller: android-app://org.polymorphicshade.tubular
  subject: Can Curiosity Heal Division? | Scott Shigeoka | TED
  url: https://www.youtube.com/watch?v=nT1MYWOFgJo
  device_id: a7cfbe1b0133ba3f
origin: REMOTE
time_fired: "2024-12-07T08:25:19.129804+00:00"
context:
  id: 01JEG3J8GS4SQB9ZDG4SRREHRW
  parent_id: null
  user_id: 1f269cc5e671416fb656d4f9e3ad1b0c

I can extract the url, for instance with:

variables:
  url: "{{ trigger.event.data.url }}"

How can I get from device_id, context id or user_id a reference to notify.mobile_app_my_phone_name?
I have one device per user, so even if I have the user id mapped to the user, I could have some manual mapping.

Are there any guides on handling this? Thanks!

variables:
  url: "{{ trigger.event.data.url }}"
  user_id: "{{ trigger.context.user_id }}"

Thanks, but getting the user id is not the problem. The problem is getting the mobile app reference to know where to send the notification.

For now, having just a few users I think I can build some ifs and trigger the notification custom for each user id… But it would be nice to have a programmatic way of doing it…

There is no correlation between user id and the name of the phone if that is what you are looking for.
If you don’t wat to use if statements then I suggest a key value pair just like in the example of template editor.

Thanks for the clarification! I managed to get it working with a bunch of ifs. I’ll post the whole solution in a few days, after I iron out some small issues.