Scheduled auto-update for Home Assistant

Hi, tonight updated 2 addons, HAOS is not updated - CoreState.FREEZE error, backup is done.

Auto-update Done! triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
06:02:44 - 2 hours ago
Auto-update Running post-update actions... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
06:02:44 - 2 hours ago
Auto-update Restart variables: input_restart_bool: True, restart_count: 0, restart_entities: [] triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
06:02:44 - 2 hours ago
Auto-update Remaining updates: - Home Assistant Operating System Update triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
06:02:44 - 2 hours ago
Auto-update Finishing update process. triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
06:02:44 - 2 hours ago
Auto-update Updating Home Assistant Operating System Update of ['update.home_assistant_operating_system_update'] ... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:02:44 - 3 hours ago
Auto-update Starting sequence of OS update... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:02:44 - 3 hours ago
Auto-update Updating Studio Code Server Update of ['update.studio_code_server_update'] ... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:01:21 - 3 hours ago
Auto-update Starting sequence of standard updates... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:01:21 - 3 hours ago
Auto-update Updating Portainer Update of ['update.portainer_update', 'update.studio_code_server_update'] ... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:10 - 3 hours ago
Auto-update Starting sequence of standard updates... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:10 - 3 hours ago
Auto-update Backup triggered. triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:10 - 3 hours ago
Auto-update Backing up Home Assistant. triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:00 - 3 hours ago
Auto-update Running pre-update actions... triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:00 - 3 hours ago
Auto-update List of updates: - Home Assistant Operating System Update - Portainer Update - Studio Code Server Update triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:00 - 3 hours ago
Auto-update A new update is available for Home Assistant. triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:00 - 3 hours ago
Auto-update Variables: input_backup_bool: True, input_restart_bool: True, input_min_update_age: 0, input_schedule_monthday: 1, input_update_exclusions: False, input_update_exclusions_processed: [ ], updates_list: ['update.home_assistant_operating_system_update', 'update.portainer_update', 'update.studio_code_server_update'] triggered by automation Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:00 - 3 hours ago
Home Assistant Auto-update on a schedule base triggered by state of Расписание HA Update
05:00:00 - 3 hours ago - Tracese or paste code here
Logger: homeassistant.components.automation.home_assistant_auto_update_on_a_schedule_base
Source: helpers/script.py:405
Integration: Automation (documentation, issues)
First occurred: 05:02:44 (1 occurrences)
Last logged: 05:02:44

Home Assistant Auto-update on a schedule base: Update - OS: Error executing script. Error for call_service at pos 4: Error updating Home Assistant Operating System: 'OSManager.update' blocked from execution, system is not running - CoreState.FREEZE

Thanks again for one more detailed log.

Could you please check if you see anything under Settings > System > Repairs in your system?

There are currently no repairs available

@EdwardTFN thanks for the great blueprint!
Was curious on the min_update_age block. Any tips on why its commented out?

1 Like

I’ve tried to implement a way to don’t update until the update is available for a minimum time, however, as both last_update and last_change are both reset after a reboot, I don’t have any reference to use.

I have to find some time to implement something based on minor vs major versions, which will probably work even better.

Since we can now use the update. domain to update firmware and MANY of us use HA hosted in docker, it would be great if you would consider offering an option in the blueprint to ONLY update the NON HomeAssistant Core components. Or put a better way for the UI, “SKIP update of Home Assistant CORE”.

I suspect I could easily hack up the YAML from your blueprint for my personal use but seeing as you referenced this Blueprint in the Shelly thread (and I had considered using it to replace my old firmware automation script). In the end was simpler for me to revise the 14 automations I had but as mentioned might help others, and will likely consider it when/if other integration start to make use of the update domain for firmware updates (I’m talking about you LIFX!) :wink:

I’ll link to this comment in the Shelly thread where you mentioned.

Thanks for all the hard work!
–Tom

I will take a look at that during the weekend…

1 Like

So, before I jump again in the code, I’ve moved it to Github, so please feel free to suggest changes directly in the code if you think you know the solution… :wink:

This is the link: https://github.com/edwardtfn/ha_auto_update_scheduled

1 Like

I want to manually check full releases and let the patch updates run on their own. This template checks that the new version is in the same month as your installed version. Could make it more fine grain if you really needed but it’s worked in my testing. I just put it under the “Update - Core” section.

- condition: template
     value_template: >-
        {{ int(state_attr(core_update_entity,
        'latest_version').split('.')[1]) ==
        int(state_attr(core_update_entity,
        'installed_version').split('.')[1]) }}

I’m now working in a version which will allow the users to select how to behave for Core and OS updates. It still pending tests, which can take a while as I have to wait until some updates are available, so I’m not updating the main blueprint yet, but I would appreciate if some brave people want to try it and give me some feedback.
The risks are minor, as in worse case it won’t update when you want it to update or will behave as the current blueprint.
You will find this dev/test version here: ha_auto_update_scheduled/auto_update_scheduled.yaml at dev · edwardtfn/ha_auto_update_scheduled (github.com)

1 Like

Installed:-) I chose “patch”, however think the choices are confusing.

  1. All: Like All

  2. Patches only: I read this as all non major versions.

  • Like install 2022.12.4 if current is e.g. 2022.12.1
  • Do not install 2022.12.0 or 2022.12.3 if current version version is 2022.11.x
  1. Major & Minor: Not sure how this is different from “All”

  2. Do nothing, understandable

Will let you know what happens

If it works, I believe it will remove the need for the “do not update the first x days in a month”

From To All Patches only Major & minor only Don’t update
2022.11.0 2022.11.3 :white_check_mark: :white_check_mark: :x: :x:
2022.11.x 2022.12.x :white_check_mark: :x: :white_check_mark: :x:
2022.12.x 2023.1.x :white_check_mark: :x: :white_check_mark: :x:

Right!

That’s also right!

This will only install major and minor, and will ignore patches.
From 2022.11.0 to 2022.11.3 will be ignored (patches).
From 2022.11.x to 2022.12.x will be updated (minor update).
From 2022.12.x to 2023.1.x will be updated (major update).

I will clarify this in the description… Later… :grinning:

Thank you very much!!

I agree that this option is kind of obsolete now, but I’m afraid that removing it now will break the logic for someone already using this or even someone who still want the major updates to come automatically, but not the first on in the month.
Let’s see if we get more feedback about this.

Thanks again!!!

Still waiting for a update…

You small table give a super overview. Raises the question of why ever have the “major and minor” selected, might just be me that do not see the need for this one:-)

I agree on the “do not update first xx days”. Much easier to let it continue, some people might have a different use case where it makes sence.

1 Like

Another good point… I’m not planning to use this option myself, as I don’t see the point, and if I will ever think about removing this it is better to do now than later when some people would have selected that option…
I will remove that and let’s see how long it will take for someone ask for that functionality, then I can ask for a use case.

There is a major update scheduled for Jan 4th.

Thanks for sharing this blueprint, Edward.

As @taw123 suggested, it would be really nice to use this script for firmware updates only. Maybe it would be possible to filter on the origin of updates.

E.g. atm I have 34 ZigBee bulbs to update through Z2M. This is rather laborious as each bulb should ideally be updated separately and each update takes at least 20 minutes.

Maybe the new patches only option would be close enough.

I’m about to release a new version where you can set a different behaviour for HA Core and OS. Maybe I should have another set for Add-ons and then everything else will respect the other filters…

I will think a little bit more about this and come back next week with something, but all ideas will be very welcome.

2 Likes

The new version did not work this night. There is a 2022.12.9 waiting, and it did never start the automation. I have this in the log, yesterday during a restart of HA (07.42), at this morning 03.00 and again at 03.30. This fits to my schedule, which is from 03.00-03.30.

Logger: homeassistant.components.automation.ha_update_test_blueprint
Source: components/automation/__init__.py:500
Integration: Automation (documentation, issues)
First occurred: January 3, 2023 at 07:42:01 (3 occurrences)
Last logged: 03:30:00

Error rendering variables: UndefinedError: 'core_version_change' is undefined

and this

Logger: homeassistant.helpers.template
Source: helpers/template.py:147
First occurred: January 3, 2023 at 07:42:01 (3 occurrences)
Last logged: 03:30:00

Template variable error: 'core_version_change' is undefined when rendering '{% set exclusions = temp_input_update_exclusions | default([]) %} {% if input_core_os_update_mode == 'ignore' %} {% set exclusions = exclusions + [core_update_entity, os_update_entity] %} {% elif input_core_os_update_mode == 'patches' %} {% if core_version_change.major or core_version_change.minor or (not core_version_change.patch) %} {% set exclusions = exclusions + [core_update_entity] %} {% endif %} {% if os_version_change.major or os_version_change.minor or (not os_version_change.patch) %} {% set exclusions = exclusions + [os_update_entity] %} {% endif %} {% elif input_core_os_update_mode == 'major_and_minor' %} {% if (not core_version_change.major) and (not core_version_change.minor) %} {% set exclusions = exclusions + [core_update_entity] %} {% endif %} {% if (not os_version_change.major) and (not os_version_change.minor) %} {% set exclusions = exclusions + [os_update_entity] %} {% endif %} {% endif %} {{ exclusions }}'

Thanks for sharing your logs. I already found the bug and will fix it very soon.

Fixed!!
You can find it in the same link as before.