WTH don't I get notifications about available updates?

Home Assistant has its own Persistent Notifications. It would be great if information about available Home Assistant / Supervisor / Operating System updates was displayed in the notification drawer in web UI.

Don’t forget your own vote

1 Like

There is a sensor for Home Assistant updates. It’s up to you to automate it. Not everyone may want alerts bugging them about this.

If you want a sensor that updates more than once a day:

sensors:

- platform: version
  name: Installed Version
  image: intel-nuc # change for your system, see https://www.home-assistant.io/integrations/version/
  source: local

- platform: version
  name: Latest Version
  image: intel-nuc # change for your system, see https://www.home-assistant.io/integrations/version/
  source: hassio

automation:

- alias: 'Update Available'
  trigger:
    platform: template
    value_template: "{{ states('sensor.latest_version') != states('sensor.installed_version') }}"
  action:
    service: notify.telegram_system
    data_template:
      title: '*Information*'
      message: "An update for Home Assistant is available. You are running {{states('sensor.installed_version') }}, the latest version is {{ states('sensor.latest_version') }}."

An OS update sensor would negate the need for adding this (so you get my vote):

sensors:

- platform: command_line
  name: HassOS Installed Version
  command: 'curl http://supervisor/host/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)"|jq ''{"hassos":.data.operating_system}'''
  value_template: "{{ value_json.hassos[7:] }}"

- platform: rest
  resource: https://s3.amazonaws.com/hassio-version/stable.json
  name: HassOS Latest Version
  value_template: '{{ value_json.hassos["intel-nuc"] }}'
  scan_interval: 3600

automation:

- alias: 'HassOS Update Available'
  trigger:
    platform: template
    value_template: "{{ states('sensor.hassos_installed_version') != states('sensor.hassos_latest_version') }}"
  action:
  - service: notify.telegram_system
    data_template:
      title: '*Information*'
      message: "Update for HassOS available, from v{{ states('sensor.hassos_installed_version') }} to v{{ states('sensor.hassos_latest_version') }}"

Sensors for the supervisor aren’t needed as this updates automatically whether or not you think this is a good thing. However if you want it now (or this WTH does not get a PR):

sensors:

- platform: template
  sensors:
    supervisor_installed_version:
      friendly_name: "Supervisor Installed Verion"
      value_template: "{{ state_attr('sensor.supervisor_updates', 'current_version') }}"
    supervisor_latest_version:
      friendly_name: "Supervisor Latest Verion"
      value_template: "{{ state_attr('sensor.supervisor_updates', 'newest_version') }}"

automation:

- alias: 'Supervisor Update Available'
  trigger:
    platform: template
    value_template: "{{ states('sensor.supervisor_installed_version') != states('sensor.supervisor_latest_version') }}"
  action:
  - service: notify.telegram_system
    data_template:
      title: '*Information*'
      message: "Update for Supervisor available, from v{{ states('sensor.supervisor_installed_version') }} to v{{ states('sensor.supervisor_latest_version') }}"

Also, just for completeness:

HACS notification:

- alias: 'HACS Update Available'
  trigger:
    platform: state
    entity_id: sensor.hacs
  condition:
    condition: numeric_state
    entity_id: sensor.hacs
    above:  0
  action:
  - service: notify.telegram_system
    data_template:
      title: '*Information*'
      message: "Update for {{ state_attr('sensor.hacs','repositories')|map(attribute='display_name')|list|join(', ')  }} available."

Addon notification:

- alias: 'Addon Update Available'
  trigger:
    platform: state
    entity_id: sensor.supervisor_updates
  condition:
    condition: numeric_state
    entity_id: sensor.supervisor_updates
    above: 0
  action:
  - service: notify.telegram_system
    data_template:
      title: '*Information*'
      message: "{{ states('sensor.supervisor_updates') }} Addon update(s) available."
7 Likes

You can of course use automation for this. But in my opinion, this is standard functionality that should work out of the box. An automation platform should make our life easier, not complicate it, right?

1 Like

For sure which is why I also said:

how do you create the sensor.supervisor_updates ?
Does this sensor also show the individual add-ons that have an update?

Sorry, I missed that one:

- platform: command_line
  name: Supervisor updates
  command: 'curl http://supervisor/supervisor/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)"|jq ''{"newest_version":.data.version_latest,"current_version":.data.version,"addons":[.data.addons[]|select(.version != .installed)]}'''
  value_template: "{{ value_json.addons|length }}"
  json_attributes:
  - newest_version
  - current_version
  - addons

haha, no worries :wink:

can I do this in Hassio OS too?

'curl http://supervisor/supervisor/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)"|jq ''{"newest_version":.data.version_latest,"current_version":.data.version,"addons":[.data.addons[]|select(.version != .installed)]}'''

thinking of the authorization here especially.

using a rest sensor myself with authorization like this:

  - platform: rest
    name: Hassio Rpi4 config
    resource: !secret resource_hassio_rpi4_config
    value_template: > #components|list|count}}
      {{value_json.version}}
    json_attributes:
      - components
      - unit_system
      - config_dir
    headers:
      Content-Type: application/json
      Authorization: !secret api_bearer_token
      User-Agent: Home Assistant REST sensor
    scan_interval: 3600

could that be done for the supervisor sensor too maybe? Trying this:

  - platform: rest
    name: Hassio Supervisor Updates
    resource: http://supervisor/supervisor/info
    value_template: >
      {{value_json.addons|length}}
    json_attributes:
      - newest_version
      - current_version
      - addons
    headers:
      Content-Type: application/json
      Authorization: !secret api_bearer_token
      User-Agent: Home Assistant REST sensor
    scan_interval: 3600

without success yet. Is the url correct? in the Config Rest sensor I need to point to https://mydomain.duckdns.org:port/api/config

when I enter http://supervisor/supervisor/info this seems incorrect?

Maybe the version platform can be modified to include an additional parameter to specify what info we want: Home Assistant, Supervisor, or Operating System.
WDYT?

1 Like

Running on Home Assistant OS the following rest sensor works for me. The addons attribute gets fully populated.

platform: rest
name: addons
resource: http://127.0.0.1:8123/api/hassio/supervisor/info
value_template: '{{ value_json.data.addons|count }}'
scan_interval: 1800 # 60 seconds * 30 minutes = 1/2 hour worth of seconds
headers:
  Authorization: !secret rest_token
  Content-Type: application/json
json_attributes_path: "$.data"
json_attributes:
  - addons

Then a template sensor I call sensor.addon_updates to count the number of addons with update_available == True. As a bonus this sensor also lists the

platform: template
sensors:
  addon_updates:
    friendly_name: Addon Updates
    icon_template: mdi:counter
    value_template: '{{ state_attr("sensor.addons","addons") | selectattr("update_available","eq",True) | map(attribute="name") | list | count }}'
    attribute_templates:
      addons: '{{ state_attr("sensor.addons","addons") | selectattr("update_available","eq",True) | map(attribute="name") | list }}'
1 Like

Thanks for this, noticed that

Was slightly off and need pushing a few characters right to get the version number, so had a dig around and stumbled on this which serves up both current an latest version for the OS - however suspect this is constrained to the once a day update that you were trying to overcome!

  - platform: command_line
    name: os
    command: 'curl http://supervisor/os/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"newest_version":.data.version_latest,"current_version":.data.version}'''
    value_template: "{{ value_json.newest_version }}"
    json_attributes:
    - newest_version
    - current_version

Anyway, thanks for the post - helpful!

Got my dashboard nearly to my liking :slight_smile:

I updated it here:

1 Like

Hi,
I have been using this for some time to detected when an update is available. As of 2021.7 it has changed and the sensor.latest_available_version does not contain the point release therefore comparison not possible.

Does anybody know a better way to trigger an alert for an update notification?

sensor.latest_available_version = 2021.7

sensor.installed_version = 2021.7.1


update_available:
value_template:  '{{ states.sensor.installed_version.state != states.sensor.latest_available_version.state }}'

The supervisor integration has binary sensors for that.

No, that integration only contains update sensors for Home Assistant OS and addons, not the core version.

Ups, my mistake, again :flushed:

Try this instead:

Thanks, worked a treat!

I’ve tried this (basically a copy of the code that @tom_l linked to above) and it didn’t trigger for me.

Can anyone see anything wrong that I’ve screwed up?

Putting the template into the developer tools tab correctly gave True when the update was available to be done. The sensors read correctly as 2021.7.1 and 2021.7.2 for current and latest (with appropriate attributes too).

alias: HASS Core Update
description: Notify if Core update is available
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.latest_core_version') !=
      states('sensor.current_core_version') }}
condition: []
action:
  - service: notify.mobile_app_darrens_iphone_11
    data:
      message: >-
        Core update from {{ states('sensor.current_core_version') }} to {{
        states('sensor.latest_core-version') }} available
  - service: mqtt.publish
    data:
      topic: scrollpi/messages
      payload: s/Core update to {{ states('sensor.latest_core_version') }} available
  - service: notify.persistent_notification
    data:
      message: >-
        Core update from {{ states('sensor.current_core_version') }} to {{
        states('sensor.latest_core_version') }} available
mode: single

The trigger needs to go from false to true. If it is already true after restarting it wont trigger. You’ll get it next time.

You could add a home assistant start event trigger as well, and a template condition, but that means you will get an alert every time you restart and there is an update available.

Just update and wait for the next one.