Notify Mobile Companion App Devices

Could you not send the yalm code to me as I can not get it to work. For your information, I have just installed another blueprint ‘Low battery level detection & notification for all battery sensors’ that worked. I am very interested as it seems like a really good project.

The only thing that I’ve done is that I have created a yaml file, shared it on Github, and wrote examples and added the shortcut to import the blueprint. So you might need to create a HA issue. I’m curious to see what the solution would be.

Anyways I can’t share the code here since it exceeds the limit of a response. So you can easily grab it from Github

I have a question: I would like to countdown when the notification fires, let’s say 3 minutes. So I would like to actively show a countdown in the notification which counts down until 0. Is that possible, if yes, how? Because I always have to specify a date in order to start the chronometer. If I only specify a number of seconds, it does not show a timer at all.

Many thanks in advance!

Parameter Description Example
data_chronometer Shows a timestamp. Notification will not disappear when the timer reaches 0. Instead, it will continue decrementing into negative values. {{now()+timedelta(minutes=3)}}
data_chronometer_enable Show a count up/down timer. Notification will not disappear when the timer reaches 0. Instead, it will continue decrementing into negative values. true

With those two enabled you should get the desired results

Does not work:

Try this:

service: 
data:
  notify_home_or_away: Both
  notify_message: Something will happen in the next 3 minutes
  data_chronometer_enable: true
  data_chronometer: >
    "{{now()+timedelta(minutes=3)}}"


Beware that I named my script script.notify_devices, so alter this to your script name

no, seems to be broken, just the same message without counter as above

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?