Can I use a parameter to specify which mobile device to notify?

Hi everyone. I’m trying to write a script that takes a mobile device as a parameter and sends a notification message to it, but can’t seem to find a way to make it work. This thread indicates that it may not be possible until the notification system is overhauled, but as it’s asking a different question, perhaps there’s a way to do what I want.

Goal: I’d like to have a script that can send a message to any mobile device, which is passed as a parameter. (The reason for this is that I’d like to send Bluetooth LE command notifications such as ble_set_transmit_power to manage power on a variety of devices; the logic will do things like turn the transmitter on if it is currently stopped )

I can send a notification to a specific device, but if I try notify.notify and add the parameter as a target, it doesn’t like it and changes it to “[object Object]”: null. It would be helpful to know if there’s any clever way to get it to work. If not I’ll need to have an ugly set of Choose options (if target_device == “pixel_7a” then notify.mobile_app_pixel_7a etc).

Thanks in advance for suggestions, or confirmation that this just isn’t possible and I have to do it the hard way!

sequence:
  - action: notify.mobile_app_pixel_7a # This works fine but is specific to a single device
    metadata: {}
    data:
      message: Test
  - action: notify.notify
    metadata: {}
    data:
      target:
        {{target_device}} # When I save, this line gets changed to "[object Object]": null
      message: Test
alias: Test Parameterised Notification
description: ""
fields:
  target_device:
    selector:
      text: null
    name: Target Device
    description: The device to send a notification
    required: true

Don’t have any experience of it but there are blueprints that does it.
Example: 📢 Notifications & Announcements

That’s from the template missing quotes, but the notify.notify action will not work that way. As the docs have warned for years…


Over the years, people in the community have shared lots of ways to address this issue.

Notify Groups
Notify Groups-based conditional Notifications

Blueprints:
Advanced Mobile Device Notifier

Custom integrations:
Universal Notifier
Supernotify

1 Like

Thanks for the correction and the confirmation.

Hi, if your issue got solved: please take the time to mark the post that holds the solution.
You do that by selecting the three dots under the post:

image

Then select the check box:

image
By doing so:

  • this thread can be useful to other users as well (this thread comes up as solution when starting a thread which is similar to yours).
  • this prevents that someone else steps in trying to help

Thanks for giving back to the community! :+1:

1 Like