Update notifications! Core, HACS, Supervisor and Addons (now a blueprint!)

Thanks. And that is why I have struggled learning YAMl. Indents are important except when they are not. It would be so much easier if only one way worked.

2 Likes

I have a notify.mobile_app_andys_iphone service so i just can change ‘me’ with mobile_app_andys_iphone?

FROM:

    notifiers:
    - 'me'

TO:

    notifiers:
    - mobile_app_andys_iphone

Yep that’ll work. Or if you find it easier, can add a notify group that wraps yours like this:

notify:
  - name: me
    platform: group
    services:
      - service: mobile_app_andys_iphone

You may be interested in https://github.com/krpn/home-assistant-updates-notification

3 Likes

(Sorry, can’t post two images in the one post.)

You may be interested in https://github.com/krpn/home-assistant-updates-notification

2 Likes

Hi There,
First, I would like to thank all the contributors here for their amazing job.
I used this post as a base for my Versions Update notifications and I would like to share my solution for anyone who would like to use it.
Among the changes to the original package shared by @CentralCommand and other shares in this post:

  1. I added DeConz Updates
  2. I added the Supervisor version check (the supervisor itself, not the addons)
  3. I re-organised the sensors to a uniform reporting state
  4. I don’t like alerts, especially many of them so I created an automation for the notifications instead
  5. I created a unified sensor with all available Updates and I am using it in my automation (and the custom UI that I won’t share here because it it out of scope)
  6. fixed minor bug with the way versions are compared (used split (’ " ') instead of chars count for some network calls, wouldn’t fail when version number passes from 0.9.1 to 0.10.0 for example)

remember to update !secret github_access_token with your github account token.
So this is my new package:

# DeCONZ Firmware Updates:
sensor:
  # Deconz Firmware version Installed
  - platform: command_line
    name: DeCONZ Firmware Installed #sensor.deconz_firmware_installed
    command: 'cat /config/.storage/core.device_registry | grep -A 3 "Dresden Elektronik" | grep "sw_version"'
    scan_interval: 3600
    value_template: '{{ value.split("\"")[3] }}'
  # HACS version Installed
  - platform: command_line
    name: HACS Version Installed #sensor.hacs_version_installed
    command: 'cat /config/.storage/core.device_registry | grep -A 3 "hacs.xyz" | grep "sw_version"'
    scan_interval: 3600
    value_template: '{{ value.split("\"")[3] }}'
# Firmware-Update-Sensor for DeCONZ Dongle
  - platform: github
    access_token: !secret github_access_token
    repositories:
      - path: 'dresden-elektronik/deconz-rest-plugin'
        name: "DeCONZ Firmware Repository" #sensor.deconz_firmware_repository
      - path: 'hacs/integration'
        name: "HACS Repository" #sensor.hacs_repository
    scan_interval: 86400 #daily
  - platform: template
    sensors:
      deconz_firmware_version:
        friendly_name: "DeCONZ Firmware Version"
        value_template: >-
          {% set new = state_attr('sensor.deconz_firmware_repository', 'latest_release_tag').replace('v', '') %}
          {% if ("beta" not in new) and (new != states('binary_sensor.deconz_firmware_installed')) %}
            on
          {% else %}
            off
          {% endif %}
        attribute_templates:
          beta: >-
            {% set version = state_attr('sensor.deconz_firmware_repository', 'latest_release_tag') %}
            {% if "beta" not in version %}
              off
            {% else %}
              on
            {% endif %}
          latest_version: "{{state_attr('sensor.deconz_firmware_repository', 'latest_release_tag').replace('v', '') }}"
          current_version: "{{states('sensor.deconz_firmware_installed')}}"
      hacs_version:
        friendly_name: "Hacs Version"
        value_template: >-
          {% if (states('sensor.hacs') | int > 0) or (state_attr('sensor.hacs_repository', 'latest_release_tag') != states('sensor.hacs_version_installed')) %}
            on
          {% else %}
          off
          {% endif %}
        attribute_templates:
          latest_version: "{{state_attr('sensor.hacs_repository', 'latest_release_tag') }}"
          current_version: "{{states('sensor.hacs_version_installed')}}"
          repositories: "{{state_attr('sensor.hacs', 'repositories')}}"
#--------------------------------------------------------
  # Sensors to track updates to core components (core, audio, dns, CLI, observer and multicast)
  - platform: command_line
    name: Core Version # sensor.core_version
    command: 'curl http://supervisor/core/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version, "update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    scan_interval: 3600
    json_attributes:
    - latest_version
    - current_version 
  - platform: command_line
    name: HassOS Version # sensor.hassos_version
    command: 'curl http://supervisor/os/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version,"update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    scan_interval: 3600
    json_attributes:
      - latest_version
      - current_version
  - platform: command_line
    name: Audio Version # sensor.audio_version
    command: 'curl http://supervisor/audio/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version, "update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    scan_interval: 3600
    json_attributes:
    - latest_version
    - current_version
  - platform: command_line
    name: DNS Version # sensor.dns_version
    command: 'curl http://supervisor/dns/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version, "update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    scan_interval: 3600
    json_attributes:
    - latest_version
    - current_version
  - platform: command_line
    name: CLI Version # sensor.cli_version
    command: 'curl http://supervisor/cli/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version, "update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    scan_interval: 3600
    json_attributes:
    - latest_version
    - current_version
  - platform: command_line
    name: Multicast Version # sensor.multicast_version
    command: 'curl http://supervisor/multicast/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version, "update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    scan_interval: 3600
    json_attributes:
    - latest_version
    - current_version
  - platform: command_line
    name: Observer Version # sensor.observer_version
    command: 'curl http://supervisor/observer/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version, "update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    scan_interval: 3600
    json_attributes:
    - latest_version
    - current_version
#--------------------------------------------------------
# Sensor to track available updates for the supervisor & supervisor addons list
  - platform: command_line
    name: Supervisor Version # sensor.supervisor_version
    command: 'curl http://supervisor/supervisor/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"latest_version":.data.version_latest,"current_version":.data.version,"update_available":.data.update_available,"addons":[.data.addons[] | select(.update_available)]}'''
    value_template: "{% if (value_json.addons | length > 0) or value_json.update_available %}on{% else %}off{% endif %}" 
    scan_interval: 3600 #check every hour (default is 60- every minute)
    json_attributes:
    - latest_version
    - current_version
    - addons

binary_sensor:
  - platform: template
    sensors:
      version_update_issues:
        friendly_name: 'Version Update Issues'
        device_class: problem
        value_template: >-
          {{ (state_attr('binary_sensor.version_update_issues', 'status')).outdated|count > 0 }}
        attribute_templates:
          status: >-
            {% set ns = namespace(outdated = [], up_to_date = [], optional_updates = []) -%}
            {%- for _updateSensor in (expand(states.sensor)|list) if _updateSensor.entity_id.endswith('_version') -%}
            {%- set _sensorName = _updateSensor.entity_id -%}
            {%- if _updateSensor.state == "on" -%}
              {%- set ns.outdated = ns.outdated + [_sensorName] -%}
            {%- else -%}
              {%- if _updateSensor.attributes.current_version!=_updateSensor.attributes.latest_version -%}
                {%- set ns.optional_updates = ns.optional_updates + [_sensorName] -%}
              {%- else -%}
                {%- set ns.up_to_date = ns.up_to_date + [_sensorName] -%}
              {%- endif -%}
            {%- endif -%}
            {% endfor %}
            {{ "{{\"up_to_date\": {}, \"optional_updates\": {}, \"outdated\": {} }}".format(ns.up_to_date, ns.optional_updates, ns.outdated) }}

And my notifications (using iOS, change the notifiers if you need):

alias: Device Health - Version Update Notification
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.version_update_issues
    to: 'on'
  - platform: time
    at: '14:00:00'
condition:
  - condition: state
    entity_id: binary_sensor.version_update_issues
    state: 'on'
action:
  - service: notify.admin_devices
    data:
      title: ⚠️Version Updates Available
      message: >-
        {%- for _updateSensor in
        states.binary_sensor.version_update_issues.attributes.status.outdated %}
          {{- "Stable Updates:" if loop.first }}
          {{- "\n "~states[_updateSensor].attributes.friendly_name ~ " [" ~ states[_updateSensor].attributes.current_version ~ "]"}}
          {%- if states[_updateSensor].attributes.current_version!=states[_updateSensor].attributes.latest_version -%}
            {{- "→["~ states[_updateSensor].attributes.latest_version ~"]"}}
          {%- endif -%}
          {%- if state_attr(_updateSensor, 'repositories') != None and state_attr(_updateSensor, 'repositories')|count > 0 -%} - repositories updates:
            {% for repository in state_attr(_updateSensor, 'repositories') %} 
              {{"\n -"~ repository.display_name }}: [{{ repository.installed_version }} ]→[ {{ repository.available_version }}]
              {% endfor %}
          {%- endif -%}
          {%- if state_attr(_updateSensor, 'addons') != None and state_attr(_updateSensor, 'addons')|count > 0-%} - addon updates:
            {% for addon in state_attr(_updateSensor, 'addons') %}
              - {{ addon.name }}: [{{ addon.version }} ]→[ {{ addon.version_latest }}]
              {% endfor %}
          {%- endif -%}
        {% endfor %} {% for _updateSensor in
        states.binary_sensor.version_update_issues.attributes.status.optional_updates
        %}
          {{- "\nOptional Updates:" if loop.first }}
          {{- "\n "~states[_updateSensor].attributes.friendly_name ~ " [" ~ states[_updateSensor].attributes.current_version ~ "]"}}
          {%- if states[_updateSensor].attributes.current_version!=states[_updateSensor].attributes.latest_version -%}
            {{- "→["~ states[_updateSensor].attributes.latest_version ~"]"}}
          {%- endif -%}
          {%- if state_attr(_updateSensor, 'repositories') != None and state_attr(_updateSensor, 'repositories')|count > 0 -%} - repositories updates:
            {% for repository in state_attr(_updateSensor, 'repositories') %} 
              {{"\n -"~ repository.display_name }}: [{{ repository.installed_version }} ]→[ {{ repository.available_version }}]
              {% endfor %}
          {%- endif -%}
          {%- if state_attr(_updateSensor, 'addons') != None and state_attr(_updateSensor, 'addons')|count > 0-%} - addon updates:
            {% for addon in state_attr(_updateSensor, 'addons') %}
              - {{ addon.name }}: [{{ addon.version }} ]→[ {{ addon.version_latest }}]
              {% endfor %}
          {%- endif -%}
        {% endfor %}
      data:
        url: /devices-health/health_panel
        push:
          thread-id: version-update-notification-group
        apns_headers:
          apns-collapse-id: version-update-issues
        presentation_options:
          - alert
mode: restart

alias: Device Health - Clear Version Update Notification
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.version_update_issues
    to: 'off'
condition: []
action:
  - service: notify.admin_devices
    data:
      title: ✅Version Updates Installed
      message: All components are up to date!
      data:
        url: /devices-health/health_panel
        push:
          thread-id: version-update-notification-group
        apns_headers:
          apns-collapse-id: version-update-issues
        presentation_options:
          - alert
mode: restart
5 Likes

Hi, I’m searching for a solution if a specific log entry is raised in log provider: host under …/hassio/system.
Is there a possibility to build a sensor that goes on if following value is in log?

cdc_acm 2-2:1.0: ttyACM0: USB ACM device

Hi everybody,

I must admit that I haven’t read the complete thread (estimated reading time: 49min - wow :slight_smile: ), so sorry if this has been asked/answered before:

Is it possible to share such an “update solution” as a Blueprint?

Best
Christian

It is shared as a package.
just create a package.device_health_notification.yaml file in your config directory and include the following ling in configuration.yaml:

packages:
    device_health_notification_pack: !include package.device_health_notification.yaml

Not currently. You can only make a blueprint of an automation and automations can’t run commands on the command line or make http requests directly, both of which are needed to check for updates. Most of this work is sensors which do just that and the only easy way to share a bunch of sensors is a package that you must manually include.

Hopefully someday blueprints can include other config besides automations they depend on. Or even better, make a blueprint of a package itself. Then could just prompt the user for the notifier they want to use and be all set.

1 Like

Just a basic question as I´m finally looking into https://www.home-assistant.io/integrations/alert/ : alerts can only be created from yaml and therefore HA always needs to be restarted to read new alerts or changes on existing ones, right?

That´s really painful once you´re getting used to the quick “change and test” mode when using automations for notifications. Is there any way to avoid needing to restart HA?

Yea I know, it’s quite a bummer alerts didn’t get made reloadable from the UI as part of WTH month like so many other things. I still really like that they build in nagging reminders and those survive restarts but now I have to weigh the need for that against easy changeability. One notification when the update is available is probably enough, nagging reminders periodically might not be worth the hassle.

Although actually even automations can approximate alerts pretty closely. This nagging reminder blueprint is basically an alert as an automation for all intents and purposes.

A few posts up Hananv shared a package that uses an automation instead of alerts. If you want to switch I’d recommend taking a look at it. Can either bring it in as a base or use at as an example and replace the alerts in mine with an automation like that. Or if you want the nagging reminders then just drop the alerts from the package entirely and make a bunch of copies of the blueprint I linked instead, one per update sensor you want to get notified about.

Hey Folks :slight_smile:

I am also looking for a update status / notfier for my Home Assistant OS - but I read this topic till page 15 and I gave it really up!

I found node-red examples…
The URL “http://supervisor/supervisor/info” dont exist on my network - so the first post cant work for me…

In my opinion: this thread is confusing :frowning:
Is there an easy way to implement ?

If by this you mean you are trying to hit it via curl or something from your laptop then yes that won’t work. That URL only exists within the docker network when you are running supervisor. So HA can hit it since its running from within that docker network but you can’t hit it from your laptop.

Yes. The first post has two packages. The first notifies you of updates to Core, Addons and HACS packages. The second does all that and also adds update notifications for all the other supervisor components (audio, dns, cli, etc.) Pick one and drop it into your config as a package. If you need help understanding how to do that, take a look at the packages doc.

Lol ? I am working with docker since years and never saw an internal communication using http proto :o

Oops didnt recognized the drop down menus in your first post :smiley:
And thank you for your help - But I will test in tommorow… to much headdache lol

If I have questions I will write to you :slight_smile:

Well I can’t say I’m an expert on it but I’m pretty sure that’s all part of what supervisor does. The dev team always says supervisor is more then just a basic docker network. One of the things it does I believe is facilitate intercontainer communication. You can refer to the supervisor container from within the network at http://supervisor, the home assistant container at http://homeassistant, and other addons at http://<addon slug>. Or https for things running that way.

There’s probably lots of other tricks too, I feel like I discover new ones all the time lol.

True I can feel you - welcome in the docker world. Thats a normal feeling as I can say :smiley:

I didnt checked the structure of the core container from home assistant - limited time you know ? :smiley:

EDIT: I Imported your package file -> works great, but unfortunately without HassOS Update notification…
But I found a way to implement it by myself :slight_smile:

cant find the correct thread for my Stats question, so please allow me here, and point me to it if needed…

we have several Stats sensors for all add-ons, and Supervisor and Core, but I can make a Host sensor, like

  - platform: command_line
    name: Stats Host CPU
    command: >
      curl -sSL -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/host/stats
    unit_of_measurement: '%'
    value_template: >
      {{value_json.data.cpu_percent|round(2)}}
    scan_interval: 60
    json_attributes:
      - data

isn’t this possible, or am I simply using the incorrect path.
thanks for having a look

The available paths for Host in the Supervisor REST API can be found here. I don’t see a /stats (and get a 404 when I try). I think you’re looking for /info as that gives me a response like this:

{
    "result": "ok",
    "data": {
        "chassis": "embedded",
        "cpe": "cpe:2.3:o:home_assistant:hassos:5.12:*:production:*:*:*:odroid-n2:*",
        "deployment": "production",
        "disk_free": 77.1,
        "disk_total": 113.9,
        "disk_used": 31.1,
        "disk_life_time": 10.0,
        "features": [
            "reboot",
            "shutdown",
            "services",
            "network",
            "hostname",
            "hassos"
        ],
        "hostname": "homeassistant",
        "kernel": "5.9.16",
        "operating_system": "Home Assistant OS 5.12"
    }
}

Although unfortunately I don’t see anything about cpu utilization in there so I’m not sure if there’s a way to get to that. There’s a lot of APIs though, others on host as well as some on hardware. Perhaps that info is somewhere in there?

Alternatively, you saw the system monitor integration right? I use that to get this info on my host currently. If you just want to get at the number that might be easier? Although not sure what other metrics you were hoping for in data, it has a limited set of metrics it exposes.

thanks! I hadn’t seen tat page, and what a nice page it is, with the fold out response values. cool.

yes, I was looking for the memory usage, to have the 3 of them, Host, Core and Supervisor be displayed in a nice graph somehow, probably test it with the new circular apex charts-card …

yes, I do have the system monitor, but am not sure which usage that shows. Is it the total for all 3?

given the fact we doing have anything but used space in the supervisor window:

I am still trying to figure out what’s what… because I also see:

which seem to have no obvious connection with the supervisor panels