Notify Mobile Companion App Devices

Have you downloaded the latest version from GitHub?

yes, of course

Oke please create an issue at Github with a trace log attached. Then we can debug it over there

Since updating to Android 14, persistent notifications are no longer persistent and can be swiped away. Anybody else seeing this?

Thanks for sharing. Mine is still on 13, but the update to 14 is expected ‘soon’. Have you reported/checked it at the Github of Home Assistant - Android?

So it would mean that if you were to send something like this in the Services that this message would not persist?

service: notify.mobile_app_<your mobile app device>
data:
  title: Is it sticky at Android 14
  message: Can you remove this sticky message in Android 14?
  data:
    notification_icon: mdi:note
    tag: test
    persistent: true
    color: '#ff0000'

FYI, to remove it use:

service: notify.mobile_app_<your mobile app device>
data:
  message: clear_notification
  data:
    tag: test

So trying to set up notifications from NFC tags. (Currently trying to create a laundry timer)

The NFC tag returns the device ID and the user id is there an easy way to convert that to use with this script to only send the notification to that device?

I did find this template which can convert the user id returned to a person (which is tied to a companion app) but I’m not sure how to go from that (or the device ID) to an input with this script to only send to that device.

I believe I have figured this out but can’t use the visual editor

service: script.1697731440614
data:
  notify_message: test from the script
  notify_devices:
    - "{{ trigger.event.data.device_id }}"

That seems to work (I need to get my wife’s phone to be 100%) and only send the notification to the device that triggered it.

But you should be able to set everything up choose any device for who you want to notify then just switch to yaml to put in the template.

Yep, confirming that when I send this via Developer Tools → Services, the notification can be dismissed by swiping it away. I’ll look at submitting a bug report now.

unfortunately this is new android behavior.

https://developer.android.com/about/versions/14/behavior-changes-all#non-dismissable-notifications

the workaround is to listen for the notification cleared event and send it back.

1 Like

I had this working and for whatever reason it has stopped working. It seems to hit the first step in the trace and just skip to the end. I am fine with providing more information, but this is what i see. What is going wrong? It says action has run successful…but no notification.






The script itself is too big to post on this forum. Let me know what you need to see based on the screenshots i can provide.

In the recent version I have made some fixes to determine the Home and Away part. Did you already tried downloading the latest version?

Could you select the Repeat part and then the Changed Variables
image

Because if your device_tracker -entity has the state home then as a result the notify_devices_away variables is empty, and then you will get the behaviour (the [])as you’re describing…

1 Like

Apologies for the dumb question, but can someone explain to me how using this script is better than using automations method?

In your automation you can simply call this service, making you live easier to maintain it. So in the end the service does the same thing, but you don’t have to go through the whole documentation.

My current counter is now on 56 automations that uses this service. If I would update the service, then I don’t have to redo all other 56 automations, since they all point to this single service.

Have a look at the examples that you can use in your automation: Useful examples

2 Likes

Thanks for the explanation, also wondering what’s the difference between this script and this one?

I recently discovered this blueprint and would love to put this to use.

After an assortment of tests, I think I’m seeing a bug that prevents messages from being sent. It is coming up with the wrong notify.[device name]. The notify.[device name] may have been a valid entry in the past - but it is not now.

I have removed the blueprint, redownloaded, performed restart… it’s just not working. If I send a notification without the blueprint - those work.

I have tried the blueprint function with “both” and “home” and the messages don’t go through. They do, however, say it’s looking for a service that doesn’t exist; this applies both to my phone and my wife’s phone.

Flip side: it does work for my WearOS watch. But that’s one of three devices I’d need to hit.

I nosed around some and found a way to view the effects of the script. I’ll add what I’ve learned here, since I didn’t see it in what I reviewed.

  1. I have this working on all three device.

  2. The script looks at the device_trackers and extrapolates the notify.mobile_app_[device name] and if it doesn’t match, the script doesn’t work. For my wife’s phone, the router had reserved the non-“_2”, so her device_Tracker was [device]_2 and for mine, I had renamed the device to be more human-friendly. In both cases, this threw things off.

  3. I made sure that the device in mobile app and the device_tracker had the exact same name. Once that was done, success.

Awesome to see that you were able to find to issue and resolve it, and thanks for the feedback!

Currently there is no way to get the device services, so that is why I had to used the “find and replace” -part. But as you mentioned it did not work initially, so I’ll need to see if I can come up with some solution, since also others have noticed the same.

Is it possible to use this service with Node-RED?

I’m not using Node-RED, but it is just a “Script”, so I guess so?! Have you ran into issues? What is your experiences so far?