Notify when an addon update becomes available - version 2

Based on feedback from fellow forum user @MGHollander, I’ve updated the blueprint that will notify you when an addon update becomes available.

The original blueprint can be found here.

Description

This blueprint will send you an update when an addon update is available. An example of such update can be found below:
IMG_38278E3055B5-1

Features

  • Sends the notification when the update is available.
  • Clicking on the notification brings you straight to the information page of the addon, allowing for starting the update immediately.

Prerequisites

The blueprint uses data from an addon sensor to determine the whether an update is available. This addon sensor can easily be implemented using a Rest sensor. A template can be found HERE. Make sure that the addon sensor includes at least the attributes ‘version’, ‘version latest’, ‘slug’ and ‘name’.

Note: for this sensor to work, you’ll have to generate a ‘Long-lived access token’, see this link for more information.

Blueprint

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

blueprint:
  name: Addon update notifications
  description: Sends an update to a selected notifier when an update of an addon is available.
  domain: automation
  input:
    addon_sensor:
      name: Addon sensor
      description: "This sensor contains the version information of the addon and should include the attributes 'version', 'version latest', 'slug' and 'name'."
      selector:
        entity:
          domain: sensor
    notify_device:
      name: Notify device
      description: "The device where the notification should be sent to."
      selector:
        device:
          integration: mobile_app

variables:
  sensor_input:   !input addon_sensor
  version:        "{{ state_attr( sensor_input, 'version' ) }}"
  version_latest: "{{ state_attr( sensor_input, 'version_latest' ) }}"
  slug:           "{{ state_attr( sensor_input, 'slug' ) }}"
  addon_name:     "{{ state_attr( sensor_input, 'name' ) }}"

trigger:
  platform: event
  event_type: state_changed
  event_data: 
    entity_id: !input addon_sensor

    
condition:
  condition: template 
  value_template: "{{ version != version_latest }}"

action:
  domain: mobile_app
  type: notify
  device_id: !input notify_device
  message: "({{ version }} > {{ version_latest }})"
  title: "{{ addon_name }} update available"
  data:
    url: "/hassio/addon/{{slug}}/info"
2 Likes

Thanks for this, very helpful. Can the ‘resource’ for the sensor just be the internal HTTP address?

I. test the Rest but Receive tthis error :

Logger: homeassistant.helpers.template
Source: helpers/template.py:1377
First occurred: July 5, 2021, 7:03:03 PM (917 occurrences)
Last logged: 10:19:09 AM

Template variable error: 'value_json' is undefined when rendering '{{ value_json.data.state }}'

Any idea whats happens ?

Have you followed the instructions? ie

and

Yes, I think so!

Thanks! I managed to get deCONZ and Frigate working using the following resources:

deconz_addon_resource: http://internalHAIP:8123/api/hassio/addons/core_deconz/info
frigate_addon_resource: http://internalHAIP:8123/api/hassio/addons/ccab4aaf_frigate/info

One thing I discovered during my testing with Postman is that the long-lived access token must be proceeded by the word Bearer which I did not know prior. All working now.

2 Likes

Excuse for delay reply

yes I add the template sensor but is the same

the result is unknow on developper tool

  # VSCode Addon
  - platform: rest
    resource: http://192.168.1.25:8123/api/hassio/addons/a0d7b954_vscode/info
    name: VSCode Addon
    value_template: "{{ value_json.data.state }}"
    scan_interval: 60
    headers:
      Authorization: !secret token_ha
      Content-Type: application/json
    json_attributes_path: "$.data"
    json_attributes:
      - version
      - version_latest
      - slug
      - name

And in log :

Logger: homeassistant.helpers.template
Source: helpers/template.py:1718
First occurred: November 30, 2021, 11:15:06 PM (5649 occurrences)
Last logged: 12:41:08 PM

Template variable error: 'value_json' is undefined when rendering '{{ value_json.data.state }}'

and in supervisor tab log:

2021-12-01 12:42:08 WARNING (MainThread) [homeassistant.components.rest.sensor] Empty reply found when expecting JSON data
2021-12-01 12:42:08 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'value_json' is undefined when rendering '{{ value_json.data.state }}'

I’m trying to implement this.

sensor:
    # VSCode Addon
    - platform: rest
      resource: https://homeassistant.local:8123/api/hassio/addon/a0d7b954_vscode/info
      name: VSCode Addon
      value_template: '{{ value_json.data.state }}'
      scan_interval: 60
      headers:
        Authorization: 'secret'
        Content-Type: application/json
      json_attributes_path: "$.data"
      json_attributes:
        - version
        - version_latest
        - slug
        - name

I added this to the configuration.yaml
I set up the long-lived token.
I have VSCode addon installed.
I get the following error in the log.

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:268
Integration: Sensor (documentation, issues)
First occurred: 6:49:00 AM (1 occurrences)
Last logged: 6:49:00 AM

Platform rest not ready yet: [Errno -2] Name does not resolve; Retrying in background in 30 seconds

The error is just nondescript enough that I can’t find anything about it.

Try it without https! Just http

Same error.

I didn’t read the error properly. It says the name does not resolve; which could mean that the homeassistant.local does not redirect to an IP address. Try switching it with the actual IP address of your home assistant instance.

If I use
https://192.168.0.4:8123/api/hassio/addon/a0d7b954_vscode/info
I get lots of SSL errors.
If I use
http://192.168.0.4:8123/api/hassio/addon/a0d7b954_vscode/info

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:268
Integration: Sensor (documentation, issues)
First occurred: 2:08:42 PM (1 occurrences)
Last logged: 2:08:42 PM

Platform rest not ready yet: Server disconnected without sending a response.; Retrying in background in 30 seconds

I feel like I’m missing something…
While I do not believe these existed when this blueprint first came out, at this point each add-on is a Device in Home Assistant and if you turn them on, there are 6 sensors that you can use including update available sensor for this. This can be plugged directly into an automation. It is no longer necessary to generate a sensor. The logic here is valid and either an automation or a new blueprint could be made using some of this logic and the new sensor.

I’m just passing this on for folks that seem to be struggling to get this going.

I was hoping for this to be a one stop shop. I seems to tick all the boxes of notifying which adon needs updated and the version.

I did see that binary sensors are now available that will generate an event if an update is available. This fails me in several ways. First, to make this work well I would need an individual automation for each addon. I don’t like that, I prefer to have a single automation that covers all addons. Two, I haven’t figured out how to grab info from the event to tell me what needs updated. As soon as a captured event occures I should be able to do this. Finally, this tequnike don’t seem to cover all cases. Just today I got a Home Asistant Core update. This itme does not have these binary sensors.