Struggling to make use of the notification options of the Home Assistant Companion App on your mobile device? Then this script can help you in the right direction.
Ever gone through all of the options of the Companion app?, then you may have lost your self in all of the options you can pick you might be dazzled what you can do with it, let alone reapply it in another automation .
And so I noticed over the last year or so that I made more and more use of the notifications via the Home Assistant Companion App on the various mobile devices, and I loved it so much that I applied it for many automations. During that journey I was struggling with adding and fixing the code in various automations (there are +/- 40 automations where I was using it) so maintaining all of it was a nightmare. And thus I made one script that has all the logic in it to notify all or specific devices, which have the app installed, and let the automation call the script. And meanwhile use the selectors to have a UI to guide the process with all sorts of options.
Where to start?
First thing is of course following the Getting Started to configure and install the Home Assistant Companion App
Once the Home Assistant Companion App is installed and connected you should have one or more devices in the Integrations section
Features of this script
-
Use an UI to select options instead of reading the documentation
-
Able to send notifications to one or more specific device(s) or all devices
-
Send notifications based on the device(s) state:
- Home
- Away
- Both (Home and Away)
-
Send notifications to Android and iOS devices (!). The script then filters the input to what is supported per platform. Thus Android features are not send to iOS devices and visa versa.
-
Send notifications with actionable actions. The script then filters the actions per platform. Thus Android actions are not send to iOS devices and visa versa.
-
Support notifications with camera images/live feed for camera devices, also for Google Nest camera devices (!).
Then what?
- Click on this link to
- Follow the instuctions to create a new script.
- Go to the Developer Tools → Services and test the new script
- Use the ‘Go to YAML mode’ and click on the “Fill example data” to send notification example to all mobile devices
- Try out the examples (at the end of this article)
- Use the script in your automation to send notifications to your mobile device
Usefull examples
Example 1: Send a persistent notification, that the user can’t remove
service: script.notify_devices
data:
notify_home_or_away: Both
data_notification_icon: mdi:human-greeting-variant
notify_title: Example 1
notify_message: Send a persistent notification, that the user can't remove
data_group: Example
data_tag: Use this tag when you need to remove it
data_importance: high
data_sticky: true
data_persistent: true
Example 2: Send a clean_persistent notification, so the notification is removed
service: script.notify_devices
data:
notify_home_or_away: Both
data_tag: Use this tag when you need to remove it
data_importance: high
notify_message: clear_notification
Example 3: Send a persistent notification, that the user can’t remove, but automatically is removed
service: script.notify_devices
data:
notify_home_or_away: Both
data_notification_icon: mdi:human-greeting-variant
notify_title: Example 3
notify_message: Send a persistent notification, that the user can't remove
data_group: Example
data_tag: Use this tag when you need to remove it
data_importance: high
data_sticky: true
data_persistent: true
data_timeout: 30
I hope that it helps you as much as it did for me . Happy notifying!
CHANGELOG
- Release 2024.04 Feat: Android Only - Alert Once
- Release 2024.2 This version packs various fixes, breaking changes, and updates to the documentation/descriptions of the various selectors
- Release 2023.7.20 Fixes to the double notification issue for Android Auto