Home Assistant update notification

Github Gist: https://gist.github.com/Klumper/0ad49c0613606b14f1a56551e4a7d737

Explanation

I wanted to play around with the new blueprint feature. It’s a pretty simple one and it’s inspired by 📸 Send camera snapshot notification on motion :slight_smile: .
The blueprint relais on the updater integration and the newest_version and release_notes attributes.

Note: I was unable to test the Android notifications

Blueprint Code

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

blueprint:
  name: Home Assistant update notification
  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
      selector:
        entity:
          domain: binary_sensor
    notification_title:
      name: Notification title (Optional)
      description: 'Default: "Upgrade time!"'
      default: "Upgrade time!"
    notification_message:
      name: Notification message (Optional)
      description: 'Default: "Home Assistant {{ newest_version }} is available"'
      default: "Home Assistant {{ newest_version }} is available"
    delay:
      name: Delay (Optional)
      description: Wait before sending the notification
      default:
      selector:
        number:
          min: 0
          max: 60
          unit_of_measurement: seconds
          mode: slider
    notify_device:
      name: Device to notify
      description: Device needs to run the official Home Assistant app to receive notifications
      selector:
        device:
          integration: mobile_app
    include_release_notes:
      name: Include release notes
      description: Toggle if you'd like to receive the release notes within the notification, default is true
      selector:
        boolean:
      default: true
    is_ios:
      name: Is it an iOS device?
      description: Toggle if your selected device runs iOS, default is true
      selector:
        boolean:
      default: true

trigger:
  platform: state
  entity_id: !input updater
  from: "off"
  to: "on"

variables:
  updater: !input updater
  newest_version: "{{ states[updater].attributes.newest_version }}"
  release_notes: "{{ states[updater].attributes.release_notes }}"
  is_ios: !input is_ios
  notify_device: !input notify_device
  include_release_notes: !input include_release_notes
  notification_title: !input notification_title
  notification_message: !input notification_message
  delay: !input delay

action:
  - delay: "{{ delay }}"
  - device_id: !input notify_device
    domain: mobile_app
    type: notify
    title: "{{ notification_title }}"
    message: "{{ notification_message }}"
    data: >
      {% if include_release_notes %}
        {% set android_data = { "clickAction": "%s" } | format(release_notes) %}
        {% set ios_data = { "url": "%s" } | format(release_notes) %}
        {{ ios_data if is_ios else android_data }}
      {% endif %}
12 Likes

can you do some for HACS?

2 Likes

yes for me also some for hacs

Edit: Notifications were delayed but did arrive after 20 min. Perhaps you could inlcude priority?

Just a suggestion, you can actually start add-ons via the service call hassio.addon_start. So if you want you can offer users an option to start the Check HA Config add-on automatically for them before the delay and the notification. This way by the time you get the notification your config has already been checked against the new version and you know whether it works or its a problem by checking the add-on logs.

If you’re interested, the action looks like this:

data:
  addon: core_check_config
service: hassio.addon_start
4 Likes

I used that one from https://www.home-assistant.io/integrations/updater/#notification before.

BUT: it’s only for HA Core. I am looking for a update notification for

  • HA Supervisor
  • HASS OS
  • HACS

Anyone any ideas? Maybe using command line to check this?

1 Like

Hi, is it possible to use another notification platform like signal messenger instead of device?

There should be a sensor for HACS sensor.hacs which should make this work.
@Klumper perhaps you could add this to your blueprint ? the sensor is a ‘0’ to ‘1’ as far as I know.

1 Like

Actually sensor.hacs reports the number of pending updates, so you’d want to trigger at the point when it becomes not equal to zero, unless you want to get notified every time it gets incremented. In either case, here’s an example of automation you could use for these purposes. Should be fairly straightforward to model a HACS blueprint, based on @Klumper’s work above. I’ll post an update in this thread if I get around to it.

One more source of potentially useful code here

I hope you don’t mind, but I used bits of this blueprint to make my own! Thanks for your awesome blueprint I used as my starting point!

is it possible to change the channel where the message is send? now it send on my channel “disarmed” with i only use for alarm related items.