Unified Notification Blueprint with Optional Actions

Hello everyone!

Here I have a blueprint that will allow you to easily create a notification script that not only unifies notifications across all your devices, but also has flexible and optional actions that can call to other scripts if certain conditions or actions are met from those notifications.

Overview

The goal of this blueprint was to allow me to easily create notification scripts that I could call from other automations that would then allow the possibility to launch another script depending on how I interacted with the notification. I also wanted the notifications to be unified to all my devices so if I interacted or cleared a notification on one device, it would automatically clear it on the others as well.

Well, after a lot of time and effort, I finally have a very nice blueprint that makes this extremely easy and you can reuse it for all kinds of different notifications. I am using it all over the place and it makes integrating live interaction with your Home Assistant a breeze.

Features

The features of this blueprint include:

  • Inputs for the most common settings and options for notifications.
    • title
    • message
    • ID/tag
    • channel
    • importance
  • Existing notifications from the same script are overwritten with a definable unique ID to avoid duplicates.
    This comes in handy when multiple notifications could be sent using the same script in a short time period and ultimately end with one final piece of info.
  • Since the channel can be set, this allows for separate mobile notifications settings and categories for each script.
  • Notifications are dismissed on all devices when dismissed from one.
  • Up to one action can be set for mobile devices.
  • HA Dashboard notifications are included.
  • An optional timeout period can be set.
    • A second notification can be sent once this timeout is reached.
  • A total of 3 possible scripts can be called. All completely optional and not required.
    • One can be called from the action button (available only on mobile devices).
    • One can be called when the notification is dismissed (will work no matter what devices dismisses it).
    • One can be called if the timeout is reached.
  • Variables can be used for inputs to allow transferring data and information directly from other scripts.

Requirements

Here are the requirements to use this blueprint:

  • The official Home Assistant mobile app.
  • One notify group with all the devices you want notified.
  • One notify group with ONLY the mobile devices you want notified.
    To configure these groups, please see this documentation.
  • At least some understanding of automation and scripts.

Important notes and info

There are a few things to be mindful of when utilizing this script:

  • Custom actions are ONLY available for mobile devices.
    • They are set automatically by using the Action Text field.
    • They will NOT show up on the HA dashboard.
  • This will NOT work without using a notification group.
  • Dismissing/clearing notifications works on all devices, including the HA dashboard.
    • Using the Action Text field with the value Dismiss is NOT required for the Dismiss Scriptto work.
  • If the Action Text field is set to the value Dismiss, it will use the Dismiss Script and the Custom Action Script will NOT be used.
  • If a Timeout Length is not set or is set to 0, the Timeout options will NOT be used.
  • A Timeout length can be set without setting a Timeout Script.

Passing data and variables

To pass data and info from another automation/script into this one, follow these steps:

  1. Use this snippet example as your action to call the script:
data:
  message: >-
    Your message text
  action_text: Close
  timeout_message: >-
    Your timeout message
action: script.your_notification_script
  1. Call those variables in the inputs of the script like this:
{{message}}
{{action_text}}
{{timeout_message}}

These variables can be set however you like and none of them are required. You can set as many of them as you like or none at all. They are completely flexible and up to you. They support templating and everything else just like you’d use the data from the original script, so they can be extremely powerful with what info you’re able to include.

Examples

Some examples of ways I’m currently using this script.

Garage door notifications

Open/Close

I notify myself when the garage door open/closes and include the option to close/open it again right from the notification utilizing the custom action script.
I also get notified as it opens and closes in case something gets stuck. I include the timestamp of exactly when the door state changed by passing this template as a variable for the message:

message: >-
  {{states.cover.garage_door.last_updated.timestamp() |
    timestamp_custom('%b-%d %H:%M')}}

    The garage door is open.

Left Open

I also monitor how long my garage door has been left open. If the limit is exceeded, I receive a notification with a 10 minute timeout. On that first notification, I give myself the option to close now with a custom action.
If I dismiss or don’t do anything with the notification, the garage door will be closed at the end of the timeout by using the timeout script.

TV Sleep Timer

Sometimes I fall asleep while watching TV. I have a timer set for 1 hour. After 1 hour, I receive a notification with a Dismiss custom action and a 10 minute timeout.
If I dismiss or clear the notification, or tap the custom Dismiss action, the timer is reset for another hour.
If I do not interact with the notification, because I’m asleep or forget, then the timeout script is called and my TV will turn off.

Normal Notifications

Since the actions and scripts are completely optional and not required, I can simply send notifications using the script without anything fancy. Having this as a blueprint makes it easy and means I don’t have to remember all the extra options available for notifications.
Because the notifications are unified by default in this blueprint, when I dismiss the notification from my phone or watch, it’s dismissed everywhere else, too. This reduces the amount of piled up notifications on other devices a ton.

“Bedtime”

I have an automation that triggers a set of actions when a “bedtime” schedule turns on.
I use this notification script with a 10 minute timeout and a Dismiss custom action to send a notification once the schedule turns on.
If I dismiss/clear the notification or tap the Dismiss button, it will cancel the automation for the evening.
If I do not interact with it before the timeout, then the automation will continue.

These are just a few of the many ways I am using this script and the almost infinite ways it could be implemented. I would love to hear all the ways you come up with and hope it helps expand the functionality of Home Assistant as much as it has for me!

If you have any questions or run into issues, post a reply and I will try to answer or fix them.

Thanks and enjoy!

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

2 Likes