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

Well to start you probably have to add verify_ssl: false to your sensor. Since that’s a local IP address whatever SSL certificate you are presenting is either self-signed or for a different domain entirely since CAs won’t issue SSL certificates for private IP addresses.

Also it looks like you’re providing Content-Type: application/json as a header which is weird since its a GET call and has no request body. Did you mean to put Accept: application/json to specify that you want JSON back? Not sure if that’s necessary or not but it makes more sense then providing Content-Type without a postbody.

Also only you can verify this but make sure your llt_addons secret is of the format Bearer <a valid token>.

I’m guessing it was blowing up on the SSL certificate since it looks correct other then that. Maybe the extraneous Content-Type header but most APIs just ignore that on a GET call.

1 Like

Why didnt that occur to me before…
The verify_ssl did the trick. Big thanks!

Update notifications don´t work sometimes, sometimes they do. E. g. update to HA Core 2021.1.4 is shown in the UI, but did not fire my automation.

Any idea what to check?

Clearly available:



Automation with notification:
Last time fired: two days ago (for HA Core 2021.1.3)
grafik

alias: Notify_System_Update HA Core verfügbar
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.updater
    to: 'on'
condition: []
action:
  - service: notify.all_devices
    data:
      title: "Update available \U0001F7E2"
      message: >-
        HA Core {{ state_attr('binary_sensor.updater', 'newest_version') }} is
        available.
      data:
        subtitle: ''
        push:
          thread-id: updates-notification-group
mode: single

Huh, that is really confusing. I’ve had issues with not receiving notifications before due to end device state but never with ha not firing an automation when it obviously should. If you go to developer tools you can manually set binary_sensor.updater to on and off to test it. Does it work when you do that at least?

Yes, this time it worked.
grafik

Really strange. Even HA reboots should not affect the automation trigger detection I guess. I have absolutely no idea… logs empty of course.

Will continue monitoring this a few more days/weeks.

Next occurence:

Supervisor shows HA Core update:
grafik

HA Core Updater (“binary_sensor.updater”) states:
grafik

This seems to not be related to the additional update sensors at all, but it´s very strange… did someone else discover this behaviour too?

That binary sensor only updates once a day so you cannot rely on it.

Well… that´s okay if it´s not a security update. Higher update intervals would be a possible solution.

it’s hard coded for that binary_sensor. This thread gives you other ways to be notified almost immediately so if that is a concern for you, use that rather than the binary sensor.

Not sure if you´re familiar with this thread… I spent many hours here, so… look :slight_smile: :

Well I have posted to it a bunch of times so I guess I’m familiar.
I don’t use his sensor as I already had my own…

Yea that’s my bad, I need to update that. Early on after I posted it and started using this package one of the first things I noticed was that binary_sensor.updater was wayyyy too slow for me. When I started digging into making update sensors for the other components of supervisor (after @DavidFW1960 pointed it out actually) I realized I should just make my own for core. I mentioned it here:

There’s two packages on the initial post. One is the base package that I posted initially, the second one includes a lot more update sensors for the various supervisor components and includes a much faster sensor for core. Here it is if you want to add it. With this one you can set the scan_interval to whatever you want:

sensor:
  - platform: command_line
    name: Updater Core
    command: 'curl http://supervisor/core/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"newest_version":.data.version_latest,"current_version":.data.version, "update_available":.data.update_available}'''
    value_template: "{% if value_json.update_available %}on{% else %}off{% endif %}"
    json_attributes:
    - update_available
    - newest_version
    - current_version
2 Likes

Other automations (e. g. for Supervisor Addons) don´t trigger too from time to time.

What do your automations look like @CentralCommand?

Until now I checked if the updater sensor switched to “True” to fire my notification.
That obviously didn´t work reliably, maybe (wild guess) because that switch to “True” sometimes happens during HA restarting and the automation doesn´t get triggered (due to maybe HA not being fully started yet?).

Now I´m thinking of setting a time pattern as trigger (e. g. “every 3 hours”) and setting the check if sensor state is “True” as a condition.

Problems with this strategy:

  • Obviously:
    notifications/actions will be fired every time according to time pattern. Receiving a notification ONCE is enough… don´t know how to work around that from the automation perspective
  • Possibly:
    ending up in the same situation (automation not getting triggered).

I was wondering how you guys set up your notification automations.

Just triggering on the sensor changing to the true state, I’ve never missed one.

So like I do. No idea why notification automations don´t trigger sometimes.

When I manually set the sensor in the developer settings, automation triggers instantly:

So still a complete miracle to me why it´s not reliably working…
(one indication: there is a correlation between automations not being triggered when sensor state changes and at the same time or only few minutes before HA is being restarted)

  1. HA restarted @ 19:00:33
    grafik

  2. Updater sensor changed state to true @ 19:02:22

  3. Automation history: it did NOT fire…


    History should contain an entry like
    Has been triggered by state of sensor.updater_addons @ roughly 19:02:XX - but it doesn´t :frowning:
    Let´s see what others use or if someone has an idea.

I have had issues with triggers not firing when the state changed during a restart. I can’t think of any specific examples off the top of my head but it is something I’ve struggled with before.

But I actually don’t use automations at all with update notifications. In the package at the top you can see there’s a whole bunch of alerts, that’s what I use. They’re basically automations specifically for the use case of notifying you of a situation.

I have noticed with alerts that occasionally I’ll miss the first one for a similar reason (state changed during a restart). But that’s not a big deal with alerts since they have a built-in reminder feature so I’ll get the second one even if I somehow miss the first.

Hi, I have problems with alerts the reference sensors are ON but the alerts remain on idle.

Only the HACS alert works for me

I’ve never seen that. Really don’t know what to make of that. Might have to report a bug I guess but its not something I’ve ever seen and I use tons of alerts in my system for all sorts of things.

I really like these notifications! Most of the updates appear on my phone when available, which allows me to install them faster.

Today I received a notification that a new supervisor update is available. When checking in HA, i also see that there is a new OS version available:

image

For the OS version, there is no notification. Are you planning to extend your notifications to include the Hass OS update also?

Here’s what I use.

Automations:

- alias: 'HassOS Stable Update Available'
  trigger:
    platform: template
    value_template: "{{ states('sensor.hassos_installed_version') != states('sensor.hassos_latest_stable_version') }}"
  condition:
  - "{{ states('sensor.hassos_latest_stable_version') not in ['unknown', 'unavailable', 'none'] }}"
  - "{{ states('sensor.hassos_installed_version') not in ['unknown', 'unavailable', 'none'] }}"
  action:
  - service: notify.telegram_system
    data:
      title: '*Information*'
      message: "Stable update for HassOS available, from v{{ states('sensor.hassos_installed_version') }} to v{{ states('sensor.hassos_latest_stable_version') }}, see https://github.com/home-assistant/operating-system/releases/tag/{{ states('sensor.hassos_latest_stable_version') }}"

- alias: 'HassOS Beta Update Available'
  trigger:
    platform: template
    value_template: "{{ states('sensor.hassos_installed_version') != states('sensor.hassos_latest_beta_version') }}"
  condition:
  - "{{ states('sensor.hassos_latest_beta_version') not in ['unknown', 'unavailable', 'none'] }}"
  - "{{ states('sensor.hassos_installed_version') not in ['unknown', 'unavailable', 'none'] }}"
  action:
  - service: notify.telegram_system
    data:
      title: '*Information*'
      message: "Beta update for HassOS available, from v{{ states('sensor.hassos_installed_version') }} to v{{ states('sensor.hassos_latest_beta_version') }}, see https://github.com/home-assistant/operating-system/releases/tag/{{ states('sensor.hassos_latest_beta_version') }}"

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[18:] }}"

- platform: rest
  resource: https://version.home-assistant.io/stable.json
  name: HassOS Latest Stable Version
  value_template: '{{ value_json.hassos["intel-nuc"] }}'
  scan_interval: 3600

- platform: rest
  resource: https://version.home-assistant.io/beta.json
  name: HassOS Latest Beta Version
  value_template: '{{ value_json.hassos["intel-nuc"] }}'
  scan_interval: 3600