I tend not to use my front end very much and check in on the supervisor tab even less. As a result I can often have a number of add-ons with available updates and not know it. I figured it should be possible to pull the current add-on version and latest available add-on version and automate it. I’ve had this running for about a week and haven’t had any false positives. I also tested it via a simulated attribute update using the states dev tool with no issue. Finally, this morning I got my first fully automated notification that an add-on update is available.
1. Create a sensor to pull the current and latest available version of the add-on:
A few notes on the above rest sensor configuration:
a0d7b954_adguard is the add-on name hassio uses. To retrieve the name for your add-on, go to the supervisor panel, and then click on your addon. Once on the add-on page, look at the URL for that page in your browser. The name is at the end of the URL. For example this adguard add-on URL ends in /hassio/addon/a0d7b954_adguard
secret llt is a long lived token. To obtain a long lived token, go to your users profile page and scroll all the way to the bottom. Create a token and copy it in to your config. Once you close the window with the LLT you cannot view the token again so be sure to record it. My secret is formatted as follows: llt: "Bearer adfasdfadsfadsfasdfasdfasdfNiJ9.eyJpc3adfasdfasdfTZlZWQ0Nzsuperlongstring of numberslettersetc" Be sure to add the Bearer before the token and place the entire thing in quotes.
The rest sensor pulls the state of the add-on (if its running or not) and then also pulls the version which is the current running version of the add-on. It also pulls version_latest which is the latest available version the add-on can pull. A later version may be available on Github, but the add-on hasn’t synced and doesn’t see the version yet.
The rest sensor may throw errors on startup if Homeassistant can’t pull the data on startup. I just ignore these as the sensor will continue to try to update and usually does on the second try.
2. Create an automation that triggers when a new version is available.
- alias: Addon Update Available
initial_state: false
trigger:
- platform: template
value_template: "{{state_attr('sensor.adguard', 'version') != state_attr('sensor.adguard', 'version_latest')}}"
- platform: template
value_template: "{{state_attr('sensor.ssh', 'version') != state_attr('sensor.ssh', 'version_latest')}}"
action:
service: notify.home_assistant
data_template:
title: "Add-On Update Available"
message: "The {{ trigger.to_state.attributes.friendly_name }} add-on is currently running version {{ trigger.to_state.attributes.version }} and version {{ trigger.to_state.attributes.version_latest }} is available."
A few notes on the above automation configuration:
The initial_state is set to false. This means that this automation won’t run unless its turned on. This is done to prevent the automation providing false positives or triggering when the sensors update on a restart. I turn this automation on after boot in another automation which I will show later.
Update service: notify.home_assistant to your applicable notification service.
You can add many add-ons to the same automation. I have all mine in one automation. The SSH add-on is added to the config above as an example on how to add additional add-ons. The message will automatically provide the name of the add-on that triggered the automation.
If two add-ons were to update at the exact same time, I am not sure how it would be handled. I think this is a pretty rare occurrence.
3. Optional - Create a switch to show/control the add-on state and an automation to turn the other automation on at startup.
I run this automation to delay some automation and get a notification when Home Assistant starts. There are other ways to delay an automation triggering via condition but this is how I do it.
- alias: Home Assistant Started
trigger:
platform: homeassistant
event: start
action:
- delay:
minutes: 1
- service: homeassistant.turn_on
entity_id: automation.addon_update_available
A few notes on the above automation configuration:
This is another possibility where the timing of things could work against you. If the add-on updated during this 1 minute delay you wouldn’t get a notification. Again, I think this is a pretty rare occurrence.
deconz => a few updates ago , it broke the complete system
mqtt & web => this rls told it was going to be deprecated , use the original mqtt addon
smb => i remember, anonymous was deprecated
check home assistant => new version fixed a bug…
other add-ons => ingress support …
But the release notes won’t say ‘this is broken, don’t upgrade’, so even with this method you’ll still upgrade the addon, find the fault, roll back and wait for the next one.
Again, you’re still going to update to this version and then move over to a different one at your leisure
Didn’t affect anyone who had their addon set up properly in the first place.
So surely you want the new version straight away
Ingress support was a long time ago. As was the samba issue. Addons have come on a long way since all of that.
If anything that auto-updates is really going to break anything it’s the supervisor, which automatically upgrades anyway and you don’t have a choice
What would be nicer would be a persistent notification that said “the mqtt addon has been updated, here’s the release notes… Deprecated…” etc.
Hey @silvrr, started using those sensors, but for the first time ever, when i rebooted HA? it went it safe mode, is it maybe because of error below, i have configured 5 , maybe it makes to many attempts at first boot when system is not ready yet?
is it maybe possible to have some kind of first delay for that rest sensor at boot?
2020-03-05 23:21:26 ERROR (SyncWorker_3) [homeassistant.components.rest.sensor] Error fetching data: https://192.168.0.17:8123/api/hassio/addons/core_deconz/info failed with HTTPSConnectionPool(host='192.168.0.17', port=8123): Max retries exceeded with url: /api/hassio/addons/core_deconz/info (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd6b0873fd0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2020-03-05 23:21:26 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 30 seconds.
2020-03-05 23:21:26 ERROR (SyncWorker_3) [homeassistant.components.rest.sensor] Error fetching data: https://192.168.0.17:8123/api/hassio/addons/a0d7b954_portainer/info failed with HTTPSConnectionPool(host='192.168.0.17', port=8123): Max retries exceeded with url: /api/hassio/addons/a0d7b954_portainer/info (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd6b07d6550>: Failed to establish a new connection: [Errno 111] Connection refused'))
2020-03-05 23:21:26 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 30 seconds.
2020-03-05 23:21:26 ERROR (SyncWorker_3) [homeassistant.components.rest.sensor] Error fetching data: https://192.168.0.17:8123/api/hassio/addons/core_samba/info failed with HTTPSConnectionPool(host='192.168.0.17', port=8123): Max retries exceeded with url: /api/hassio/addons/core_samba/info (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd6b07d6790>: Failed to establish a new connection: [Errno 111] Connection refused'))
2020-03-05 23:21:26 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 30 seconds.
2020-03-05 23:21:26 ERROR (SyncWorker_3) [homeassistant.components.rest.sensor] Error fetching data: https://192.168.0.17:8123/api/hassio/addons/core_mosquitto/info failed with HTTPSConnectionPool(host='192.168.0.17', port=8123): Max retries exceeded with url: /api/hassio/addons/core_mosquitto/info (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd6b07fc590>: Failed to establish a new connection: [Errno 111] Connection refused'))
2020-03-05 23:21:26 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 30 seconds.
2020-03-05 23:21:26 ERROR (SyncWorker_3) [homeassistant.components.rest.sensor] Error fetching data: https://192.168.0.17:8123/api/hassio/addons/a0d7b954_ssh/info failed with HTTPSConnectionPool(host='192.168.0.17', port=8123): Max retries exceeded with url: /api/hassio/addons/a0d7b954_ssh/info (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd6b084e510>: Failed to establish a new connection: [Errno 111] Connection refused'))
2020-03-05 23:21:26 WARNING (MainThread) [homeassistant.components.sensor] Platform rest not ready yet. Retrying in 30 seconds.
I manually update because I want to know what’s new in each new release. If an add-on auto-updates, I might miss a new feature I want to use.
I also like to make sure I have an up-to-date snapshot before updating, especially with my more “mission critical” add-ons like AppDaemon and Bitwarden, just to make sure I have my updated data to restore from in case something goes wrong.
hey, tried now with nabucasa url’s, but its the same …
on first reboot , i have 5 errors for my 5 sensors, i think its already requesting info, while my system is not yet ready … on next scan_interval its succeeds
i should find a way to have some startup delay for those sensors…