Auto Update feature for Core/Supervisor

I was able to get this working for minor updates but not for the Home Assistant Operating System. (at least versions 8.0 and 8.1 have shown pending and have not been automatically applied.)

Here is how I have it configured:

Here is the YAML version:

alias: Auto Run Upgrades
description: ''
trigger:
  - platform: time
    at: '04:00:00'
condition: []
action:
  - service: update.install
    data:
      backup: true
    target:
      device_id:
        - cf94e6e1226df07e485561f25a050259
        - 8c6500baaa99e82110f2544d46de91b5
        - 1b9f42d0efb718b678a3b94ace7bd91a
        - 5e7ab1dc9b9d68e2e666ff6d41e9af53
        - 59c6285a9afdd0b1e94dda917c4c3f1c
        - ef9f35ecf327aead3f5107116021b7bd
        - 830014dfaeba1ed5783b7868209eea37
        - 964ddc565d7d626bdd721a24cce72100
      entity_id:
        - update.file_editor_update
        - update.home_assistant_core_update
        - update.home_assistant_google_drive_backup_update
        - update.home_assistant_operating_system_update
        - update.home_assistant_supervisor_update
        - update.node_red_update
        - update.samba_share_update
        - update.terminal_ssh_update
        - update.home_assistant_operating_system_update
mode: single

Is there something I’m missing?

My reply was only to explain how to do this. Which you didn’t do.

(maybe once a week at certain time would be fine)

Personally, I don’t think automatic updates for HA at the moment is really are good idea.

However, I can see a few things here.

  • The supervisor updates itself automatically. There is no need to automate it.
  • Most addons can update themselves automatically. No need to automate. Check the addon configurations.
  • You seem to be using a mix of device id’s and entity id’s. Perhaps this is a product of using the UI for your automations but it doesn’t make sense to me.
  • OS and Core updates are going to trigger a restart which means any other pending update won’t install until the next trigger time.
  • update.home_assistant_operating_system_update is listed twice (actually 3 times it looks like one of those device id’s corresponds to the same entity.

There was another thread about this the last few days. You might find a some useful nuggets in there.

@jazzyisj I initially had a condition so it would only run once a week but still got sick of the pending updates that would take days to clear. I now have it run every morning at 4 AM and a backup is taken at 3 AM via the Google Drive Backup add-on, plus the backup is taken by HA before doing the upgrades anyways.

I took a look through the thread you linked to and pretty much all the responses are saying “don’t this…breaking changes…” I don’t care! I have daily backups and if an auto update breaks my setup I can restore my backup within minutes. Even a full nuke and pave can be done in 10-15 mins these days. I don’t care about the risk, I just want the thing automatically updated while I’m sleeping so I don’t have to see all the pending updates.

You made a good point about the addon’s being duplicated (I have them added into this automation in addition to the “auto update” toggle on the addon itself.) I will remove them from my automation and let the toggle do it’s magic. Also good to know that the supervisor will keep itself updated as well.

Now my automation looks like this:


Not sure if choosing the “device” vs the “entity” matters, so I’ve selected both.

I’ll check back tomorrow to see if that will finally take care of this update which hasn’t been automatically applying:

Entity ID and Device ID are either or. You don’t need them both.

Anyway, we’re kinda getting away from a Feature Request here. I’d keep tabs on that other thread to see if they come up with any epiphanies over there and if you need any more assistance I’d post your question over there. There seems to be few people active in that thread.

I think it would be useful if the update service call could differentiate between the major monthly releases and the minor ad-hoc releases for Core.

I’d be fairly happy automating the minor releases of Core but not the major ones.

Thats… actually not a bad idea. A minor/major release attribute would make that easy enough.

In the meantime, you could probably figure this out yourself on a per entity basis with a template. Since every component has it’s own versioning scheme you’d have to figure out the template for each update individually.

{{ states('update.home_assistant_core_update','on') 
     and state_attr('update.home_assistant_core_update','installed_version')[:6] 
        == state_attr('update.home_assistant_core_update','latest_version')[:6] }}

{{ states('update.home_assistant_operating_system_update','on') 
     and state_attr('update.home_assistant_operating_system_update','installed_version').split('.')[0]
        == state_attr('update.home_assistant_operating_system_update','latest_version').split('.')[0] }}

Both of these should evaluate to true if there is a minor update version available.

The update.install service is still not working for the Home Assistant Operating system. This is how I have it configured. Is there something I’m missing, or have I ran into a bug?

If you’re still having an issue I’d start a new post or ask in the related thread. We’ve gotten a little beyond the feature request here :wink:

I think the link you have is wrong as that isn’t related to this but I ended up opening an issue on Github.

Oh shoot you’re right - had a link for someone else in the clipboard! Here it is.

I ended up figuring this out. Having the “Backup” option enabled causes it to fail. After disabling the option to take a backup before the update fixed the issue and caused it to run. This obviously isn’t a good idea so a work around is to use the Google Drive addon and use that to schedule a backup before the update service is called. In my case I have a backup set to run every morning at 3 AM and then an automation to run the update service every day at 4 AM. If I wake up and find my system hosed, I can download the backup from Google Drive, format my Pi, and restore from the backup taken right before the upgrade. It would be nice if the built in backup option was supported but at least for now I found a workaround.

So, there is my Auto-update Blueprint: Auto-update Home Assistant - Blueprints Exchange - Home Assistant Community (home-assistant.io)

Please give your feedback over there.

Would it be possible to match this with the breaking changes list, to validate the breaking change and if what we use is in the breaking change then don’t update and send a notification or a mail

I believe breaking changes is deprecated, no?

Is there a way to auto update to latest dot version of a previous release? IE - I want to avoid going through the dot versions that get released so instead update to the latest version of the last release. So when 22.8.0 comes out it would automatically update to 22.7.7

As of Supervisor 2022.8.5 it seems we can now disable auto updates.

I went to Developer Tools > States and selected the update.home_assistant_supervisor_update entity, and changes the auto_update attribute to false.

Hopefully this works, and I can update manually once I confirm the update won’t have any major conflicts with my addons/integrations.

That is… Not how that works. Updating the state of entities in dev tools is just for testing, it doesn’t change anything except the state of that entity. At least until the integration updates it state again with what the value is supposed to be. I would guess if you looked again you’ll see that attribute is true again.

However you are correct that you can disable automatic updates for supervisor now. To actually do that you need to enter this in the cli:

ha supervisor options --auto-update=false

Note that while supervisor is out of date nothing else can be updated. It also won’t even check for updates to addons as just reading in their config can break things if they are expecting the latest supervisor features. You also cannot install new addons or add new addon repositories.

In addition your system will be considered unsupported while supervisor is out of date as only the latest version is supported. Wanted to make sure you weren’t surprised by any of these restrictions before you changed it.

2 Likes

So that’s the reason for the auto update,
still I can imagine some smart mechanism not breaking stuff while the supervisor is out of date,

for me there seems to be some kind of contradiction,
for haos and ha core, please read through all changes before installing because you might break something and then the supervisor is just pushed whether the time suits me or not.
On the other hand, this update has never broken anything for me, still a little more consideration would be nice.

I need 2022.8.5 to use this command? Can I use this on an older version?

If you’re referring to the command in my post it came out in 2022.08.4 of supervisor. And you definitely have it because supervisor auto-updated for everyone with no ability to turn that off prior to that release.

What version of core you are on (I assume that’s what you’re referring to) does not affect what commands are available in the CLI.