UPDATED: Notify all mobile devices and HA dashboard with one script!

This script allows you to specify the title, message, unique persistent notification ID, the dismiss text, and timeout, in minutes, of a notification that is sent to all mobile devices and the HA dashboard.

Actions can be specified for when the notification is dismissed, these actions work both from the mobile notification or HA notification.
Optional actions are also specified for when the notification timeout is reached.

This was created as a sleep timer notification for my TV, but I’m sure there are many other use cases where this would come in handy.
Not having to list every device and being able to still access the notification through the mobile app or HA helps with accidental notification clearing or misses on mobile devices.

If you find a bug or want something added, let me know!

UPDATE 1: The original link posted was broken. The current one is tested and works to import!

UPDATE 2: I ran into issues using the notify.notify service where the notifications just weren’t coming through on my mobile apps anymore. This is addressed in the documentation. Whoops!

UPDATE 3: Both scripts are now optional. If no script is specified, no actions are taken.

Instructions below

The new and improved version actually uses 2 notify groups that you must create in the configurations.yaml file. It should look like this:

#notification groups
notify:
#all mobile devices group
  - platform: group
    name: notify_all_mobile_devices
    services:
      - service: mobile_app_device_id_1
      - service: mobile_app_device_id_2
      
#all devices group
  - platform: group
    name: notify_all_devices
    services:
      - service: mobile_app_device_id_1
      - service: mobile_app_device_id_2
      - service: persistent_notification

PLEASE READ BEFORE USE
Important information:

  • The ‘name’ value can be anything you want, but these make the most sense to me. Make sure to only use lower case and underscores. Like entity id’s.
    You MUST match the names in the respective script inputs otherwise things might get weird.
  • You will need to find your unique device id for each phone or watch you want included. This is found by going to the ‘Mobile App’ integration under settings in HA.
  • To add more devices, simply add more lines, following the same pattern.
  • ‘persistent_notification’ is what notifies the HA app on the side panel itself. There is only one.
  • The new version only accepts a script as the dismiss action and an optional timeout script if the notifications aren’t dismissed.

Features:

  • If you dismiss a notification in one place, it will automatically dismiss it everywhere else like magic!
  • ALL notifications are automatically dismissed once the timeout is reached!
  • Any new notifications coming from the same script will automatically overwrite the old ones to avoid duplicates.
  • Custom channels can be set to allow for custom notification behavior per script.

Disclaimer: Not all features available on iOS.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

1 Like

This is really awesome.
What would make it better is to be able to use this script as a call service and be able to plug in most or all the variables as data using fields. It will still work with the inputs, but it will also work by calling the script and supplying data. On mine I have for the most part opted to assume it will use !inputs unless there is data passed in. If data is passed in use that data as variables. Then you could easily use this and call it from other blueprints and supply the data ‘on the fly’.

I have a blueprint that does notification stuff but I didn’t know how to do the notify mobile part of it. I would like to suggest this BP be used there but to make it work smoothly, some or all the data would need to come in via data pass-in.

I have done similar with several of mine if you want to look at something to guide you. This works out nice to generate a basically blank script that you plug into your automation or your other blueprint, and the fields: think lets you just pick all the variables like it was part of the original automation or blueprint.

My scripts for inspiration:
https://github.com/SirGoodenough/HA_Blueprints/tree/master/Scripts.

Oh that sounds like a brilliant upgrade and would definitely make it even more usable!

You are correct that it currently uses !input to pass the data. I haven’t tested it, but I believe you could use templates in YAML mode when creating the script to get data from entities and such.

I’ve used them in the past for notifications, but not in this script. I’ll have to do some playing and see what I can come up with.

I can provide examples if needed.

I will also give your scripts a look and see if I can work anything in!

1 Like

The key is using fields: in the script to create templates and placeholders for live fed data. They are much like !inputs, little different. Look at my examples. They can co-exist with !inputs and you can see code in my examples on selecting which to use during execution.

Automation blueprints Google assistant

Hi

It’s an automation with blueprints.
This automation activate the Google Home but no music.

But the notify is ok for all users.

Can I have solution please ?


alias: "Automate Arrive de Flo à la maison "
use_blueprint:
  path: cordlord/custom_action_notification.yaml
  input:
    title: "Papa Flo arrive "
    message: Que la musique commence, papa arrive
    notification_id: Notify_ha_user
    dismiss_action: []
    timeout: "0"
    default_action:
      - service: google_assistant_sdk.send_text_command
        data:
          command: "Ok Google, play in Spotify : Star War Intro"
          media_player: media_player.cuisine
icon: mdi:bell

You’d want to re-download the new version. It uses scripts instead of actions.

Create a script to send the google command, then use that script in my blueprint.