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?
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!
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?
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.
@tom_l - I don’t think there was any restart involved. This was for the update yesterday from core 7.1 to 7.2, and nothing fired. I understand what you mean though, so it may be that I didn’t notice or something.
I’ve now updated, so I’ll keep an eye on it for next time as you say and look to do something on restarts. I have an automation already that runs on restarts, so can look to just add it to that perhaps if I can localise the conditions (or a parallel specific automation if not).
You should have restarted after adding the sensors. Also reloading automations (if that is what you did instead of restarting) will have the same issue.
I meant that there was no restart coinciding with the new core update arriving (there was of course one after it installed). The sensors have been in place and functional for a while now, so all should have (to my mind) been fully available to trigger for yesterday’s update from 7.1 to 7.2.
Anyway I’ll add the conditional check on HA start-up anyway, and keep an eye on it for next time there’s a core update to see if it notifies or not.
@tom_l - To close this one off for my earlier issue/question, just got the ping for the 7.3 update correctly and successfully. So looks like your assessment for the 7.1 → 7.2 update notification failure was on the money.
It’s even ahead of the game, as the update isn’t actually available in the supervisor yet