UPDATE 16/03/2021
Based on feedback a new version of this blueprint has been published HERE.
Hi all,
Before the blueprint-era I used the same automation over and over for each addon to notify me whenever there was an update available. With the new blueprint functionality I can make only one adjustment to the blueprint which will then apply for each automation that uses it.
The blueprint is quite simple: it sends a notification that has an URL to the addon page.
(Note: this is triggered by ‘execute’, therefore the version numbers are the same)
There is a pre-condition to use this automation: you should make sensors that retrieve the status of the addons. For the sensors, you could use the following template: https://pastebin.com/UjdmztvU
(Note: I had to use pastebin, otherwise the blueprint cannot be imported)
For the secrets:
- The token can be generated on the bottom of your profile page, see https://developers.home-assistant.io/docs/auth_api/#making-authenticated-requests
- the url is of the form https://[your-home-assistant-url]:8123/api/hassio/addons/a0d7b954_vscode/info
The blueprint itself is quite self explanatory. Note that the ‘hostname’ returns a value in the form of a0d7b954-vscode
instead of a0d7b954_vscode
to use it in the url ( /hassio/addon/a0d7b954_vscode/info
). Therefore the regex expression is used, which will replace the ‘-’ with an underscore ‘_’.
Blueprint
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 sensor and should include the attributes 'version', 'version latest', 'hostname' 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' ) }}"
hostname: "{{ state_attr( sensor_input, 'hostname' ) | regex_replace(find='-', replace='_', ignorecase=False)}}"
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/{{hostname}}/info"