Fancy Home Assistant Update Available Notifier for Android (With customizable notification settings)

Get a fancy notification when there is an update available to home assistant!

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
If you’re using an Android 8.0+ device, this blueprint will give you fancy update notifications like this one!

But the best part of all, what makes this blueprint the better choice over others available (imo), is that you can update your notifications settings for this specific notification.

And it can also group up with other similar notifications if you have multiple update notifiers

Collapsed
Expanded

Oh, and for good measure, I added a toggle (off by default) to go directly to the Home Assistant Podcast episodes list so I can listen to this release’s podcast episode before I install it.

Blueprint Code


blueprint:
  name: Home Assistant Update Notification for Android
  description: Send a notification when there's an update availiable for Home Assistant
  domain: automation
  input:
    updater:
      name: Update sensor
      description: "The sensor which indicates if there's an update. Default is 'binary_sensor.updater'"
      default: binary_sensor.updater
      selector:
        entity:
          domain: binary_sensor
    notify_device:
      name: Device to notify
      description:
        Device needs to run the official Home Assistant app to receive
        notifications
      selector:
        device:
          integration: mobile_app
    notification_title:
      name: Notification title
      description: 'What would you like to appear as the title of the notification on your device? If you put "{{ newest_version }}" in your message it will be replaced with the actual version number in your notification'
      default: Upgrade time!
    notification_message:
      name: Notification message
      description: 'What would you like the message in your notification to be? If you put "{{ newest_version }}" in your message it will be replaced with the actual version number in your notification'
      default: Home Assistant {{ newest_version }} is available
    category:
      name: Notification Category
      description: "Devices running Android 8.0+ are able to create and manage notification channels on the fly. Once a channel is created you can navigate to your notification settings and you will find the newly created channel, from there you can customize the behavior (like notication sounds, etc) based on what your device allows."
      default: Home Assistant Updates
    color:
      name: Notification Color
      description: "You can set the color of the notification, you can use either the color name or the hex code."
      default: homeassistant
    importance:
      name: Notification importance
      description:
        When you are setting the channel for your notification you also
        have the option to set the importance for the channel per notification. Possible
        values for this property are high, low, max, min and default.
      default: high
    group:
      name: Notification Group
      description:
        Setting a notifiction group will group it with other notifications
        of the same group. Useful to be able to group other update notifications together.
      default: Available Updates
    delay:
      name: Delay
      description: Wait before sending the notification
      default:
      selector:
        number:
          min: 0.0
          max: 60.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
    clickAction:
      name: Click Action
      description: "Clicking on the notification takes you where?"
      default: "https://my.home-assistant.io/redirect/supervisor/"
    include_release_notes:
      name: Include release notes
      description: 'Add a "release notes" button to the notification'
      selector:
        boolean: {}
      default: true
    include_hasspodcast:
      name: Include HassPodcast link
      description: "Add a HassPodcast button to the notification"
      selector:
        boolean: {}
      default: false
  source_url: https://gist.github.com/fortepc/042c8b3e77cc2870d803e886cc895f34

trigger:
  platform: state
  entity_id: !input "updater"
  to: "on"
  for: !input "delay"

mode: restart
max_exceeded: silent

variables:
  updater: !input "updater"
  newest_version: "{{ states[updater].attributes.newest_version }}"
  release_notes: "{{ states[updater].attributes.release_notes }}"
  include_release_notes: !input "include_release_notes"
  include_hasspodcast: !input "include_hasspodcast"
  color: !input "color"
  category: !input "category"
  group: !input "group"
  importance: !input "importance"
  notify_device: !input "notify_device"
  notification_title: !input notification_title
  notification_message: !input notification_message
  action_1_title: "{% if include_release_notes %}Release Notes{% endif %}"
  action_1_uri: "{% if include_release_notes %}{{ release_notes }}{% endif %}"
  action_2_title: "{% if include_hasspodcast %}HassPodcast{% endif %}"
  action_2_uri: "{% if include_hasspodcast %}https://hasspodcast.io/episodes{% endif %}"
  clickAction: !input "clickAction"

action:
  # Send actionable notification
  - domain: mobile_app
    type: notify
    device_id: !input notify_device
    title: "{{ notification_title }}"
    message: "{{ notification_message }}"
    data:
      persistent: "{{ persistent_notification }}"
      color: "{{ color }}"
      channel: "{{ category }}"
      group: "{{ group }}"
      importance: "{{ importance }}"
      clickAction: "{{ clickAction }}"
      actions: >
        {% set titles = [action_1_title, action_2_title, action_3_title] %}
        {% set uris = [action_1_uri, action_2_uri, action_3_uri] %}
        {% set actions = namespace(data = []) %}
        {% for title in titles %}
          {% if title|length %}
            {% set uri = uris[loop.index - 1] %}
            {% set action_name = "action" + loop.index|string %}
            {% set action = {
              "action": "URI" if uri|length else action_name,
              "title": title,
              "uri": uri 
              }
            %}
            {% set actions.data = actions.data + [action] %}
          {% endif %}
        {% endfor %}
        {{ actions.data }}

Credit

To give credit where it’s due, I didn’t come up with this on my own. I was using this blueprint but I wanted to tweak a few things, most importantly I wanted to be able to customize the notification sound to be different than my other notifications, so I needed to give it support for notification categories & groups. I also wanted to be able to make the release notes an action button on the notification instead of replacing the notification’s click action

That’s where this blueprint came in, I was struggling to figure out how to make all the syntax work with the optional action button, until I eventually just copied the action button section entirely from this blueprint.

14 Likes

I also couldn’t figure out how to do that “add to home assistant” button that other people put… so any help there would be appreciated :sweat_smile:

The fact this isn’t built into the mobile app baffles me. Nice work!

As for the link creator: https://my.home-assistant.io/create-link/

Create a gist on Github, and call it update_notification.yaml. Use the above creator and it’ll give you some markdown to copy into the post

4 Likes

Found a bug though. Input colour, even though it is optional, saving fails because it’s not set

Huh, strange. Well since I don’t know how to make things actually optional, I guess I’ll just edit it to remove the optional marking lol. It’s fixed now, I also made a small tweak adding in an click action adjustment too.

1 Like

As of now we only had a requirement to notify all users about the security bulletin. I do like this idea about notifying the admins if they want. Please feel free to submit a feature request on github, maybe we can make it an option in app configuration to notify a user on that device about a new HA update. However its only for one device, whats being offered here means a user doesn’t have to know to dig into their settings and find the option. So sometimes there are better ways to do things. Also the app wouldn’t be checking on a regular basis for updates, probably checks will be done when the app is launched. So there are some considerations here which is why a blueprint for this is nice as well :slight_smile:

2 Likes

Who wouldn’t? :rofl:

Aren’t we all admins? I know some people using homeassistant and none of their accounts are non-admins… my wifi has an account, she doesn’t even know what homeassistant is :rofl:.

So yes please build this in the app, I have now done it via nod le red but sometimes its missed…

Honestly, I think this kind of blueprint should just be pre-packaged with home assistant. Let the users decide for themselves if they want these notifications.

1 Like

Honestly, I think this way of doing it is great. If anything at all, I’d say that they can pre-package a blueprint like this one into home assistant. There’s no need to build it into the app. I’d rather the app stay as slim as possible, and just give users the option to extend it with their own automations.

Maybe if anything should be added to the app, it’s on device automations similar to tasker but that’s a conversation for another thread :sweat_smile:

1 Like

it would be better handled outside the app I think as users can determine who to send the notification to and how often. If we were to build it in the app we can do a daily check or anytime the app is opened but anything more requires something more complex and more settings which can lead to more confusion. Thats kinda where blueprints come to save the day since its easy to implement and can take care of those considerations.

1 Like

some of this has already started like high accuracy mode can be automated on the device, theres been a request to automate the bluetooth transmitter based on the zone. Best to submit individual feature requests so we can consider them on a case by case basis because sometimes it makes sense to do it on the device and other times might be better handled by the server :slight_smile:

1 Like

unknown tag !<!input> at line 82, column 30:
entity_id: !input “updater”

When I paste the code into a blueprint yaml, I get this error.

I just double checked it, and it’s working fine for me. Try using the “My Import Blueprint” button at the top of the post, maybe something weird is happening with the copy/paste?

Here’s a GitHub link if that helps https://github.com/fortepc/My-Home-Assistant/blob/0fd05c5363ae536107a22ad263e683c63d7f5141/Blueprints/update-notif-for-android.yaml

It’s not an error, it’s just that the file editor inside of the addon is a more general one, and the syntax checker wasn’t updated for Home Assistant.

Would it also be possible to add an “update now” button?

1 Like

No, not without some sort of custom component to give us a service call to update home assistant. As it is home assistant can’t be updated through automations. It has to be a person clicking the update button inside of the supervisor page.

The tap action of the notification you get though takes you directly to the update page by default.

Couldn’t you do something with the rest command component and HA’s api?

1 Like

Oh yeah, I totally forgot about that as a possibility, I’m not familiar with the HA api and this does everything I personally need so… :sweat_smile: so I’ll leave that for someone else to fork this blueprint to add that functionality if they want.

1 Like

Great job! Can you add own release notes and HassPodcast text and option for persistent?

I’ll look into that, I’m unsure how I could add release notes / hasspodcast text though. The persistent option definitely, if I do that though I’ll want a condition to when the updater turns off it will dismiss the notification if it’s set to be persistent, so no promises on a time table.