Scheduled auto-update for Home Assistant

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

=> The code is now available at Github. Please contribute with your ideas: https://github.com/edwardtfn/HomeAssistant-Config/

I’ve created a new version of my previous Auto-update Home Assistant blueprint, but now based in the new schedule helpers and other improvements. I’m using this blueprint myself.

I still think you should understand the benefits and risks of auto-updating, so I keep suggesting you to take a look on those discussions:

Please provide feedback. This is based on my other blueprint, just changing the items related to the schedule, so I believe the update mechanism itself is quite well tested, but you know, there are always new ideas or new use cases that we never though about, so let me know your ideas, issues and concerns… :slight_smile:

Important notes:

  • Supervisor update:
  • Add-ons auto-update on the UI:
    • All the standard add-ons of Home Assistant support to set “Auto-update” thru the UI. If that is enabled, this blueprint cannot guarantee the time of running the updates for that specific add-on (as it is controlled outside this blueprint).
  • HACS update:
    • At this moment (2022-09-10), HACS updates are not released, but it is an experimental feature, so, if you enable HACS to use its experimental features, this blueprint will include HACS updates automatically.
  • Schedule helper
    • You will need a schedule helper indicating the time slots where the updates could start.
    • Schedule documentation: https://www.home-assistant.io/integrations/schedule
    • The updates will be installed one by one, while inside the schedule windows. It’s not guaranteed that the update will finish inside the schedule windows.
    • Now, if one of the updates forces HA to reboot, the automation will restart after the reboot and will resume the updates of all the remaining items.

Change log:

  • 2022-09-10 06:10 UTC:
    • First time published (this version based on schedule helpers)
  • 2022-09-17 07:38 UTC:
    • Error handling - The update process will now handle errors gently and continue to the following actions
  • 2022-12-08 14:26 UTC:
    • Code clean-up (removed commented code)
    • Waiting time for backup
    • Code moved to Github.

This is the Blueprint:

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

=> The code is now available at Github. Please contribute with your ideas:

11 Likes

Get this error when installing the new blueprint.

From the log:

[546743126000] Error handling message: while scanning a simple key in "<unicode string>", line 543, column 1: </code></pre> ^ could not find expected ':' in "<unicode string>", line 544, column 1: <p><strong>Roadmap: (no promises ... ^ (unknown_error)

Could you please try to import again?
I believe some codes on the road map area (now removed) was messing up the importing.

Import and configuration works now. Will wait for a update and let you know if it works (which I expect as the old version worked with no issues)

1 Like

There are some new code compared to the old one, but the core is almost the same, so I believe it will work fine for most people. It’s working fine for me since a few updates.
This thing about scheduler is much better… Gives more flexibility and I can play with more triggers just adding a condition to never run outside that window.
I hope you enjoy this one.

OK thanks for this, but I am still very much a n00B. Is there any chance of a step by step guide to get this up and running? (I’m also the guy who posted one of the original threads to ask for this this feature).

Sure, but please let me know how far did you got?

Have you been able to import the Blueprint?

I don’t know how to import a blueprint. Essentially I have a HA instance up and running and configured. But I’ve done nothing with it, because it require frequent maintenance by me, which I just don’t have time to do. This is why I asked this question originally. It’s potentially more relevant now that Google have borked IFTTT integration with Google Home/Nest.

So, let’s start installing the Blueprint then (the process might change a bit depending on your system, but it’s basically following the steps offered to you by Home Assistant):

  1. To start, go back to my first post on this thread and click at that black and blue button saying “Import blueprint”:

  2. Then click in “Open link”

  3. Click in “Preview blueprint”

  4. Click “Import blueprint”

Now you have the Blueprint available in your system, so you can create the automation. But before that, let’s create a schedule first:

  1. On Home Assistant, go to Settings > Devices & Services, then select the tab “Helpers” in the top.

  2. Click “Create helper” (in the bottom)
    image

  3. Select “Schedule”

  4. On the schedule window, give a name for your helper and select the times for update. I suggest to do this over Voight and to allow a few hours for each window (to accommodate backup and an eventual restart if needed). Then click “Save”.

  5. Go to Settings > Automation & Scripts and click “Create automation” in the bottom.
    image

  6. Click on the box “Select a blueprint” and pick “Home Assistant scheduled auto-update” from the list.

  7. Then fill the mandatory inputs and hit save. You can leave everything that is “(optional)” for when you get more experience with Home Assistant. I highly recommend you to enable the options for backup and restart, then select the scheduler helper you created and the earlier day in a month to run the update. Maybe you should select something between 10 and 15 days to avoid all the newly released (and sometimes a bit buggy) updates on the beginning of each month.

  8. Give a name for your new automation and then click “Save”.

You are done!
Now your Home Assistant will be automatically updated on the time schedule you selected.

Hi, HAOS is not updated, CoreState.FREEZE error, only backup is done.

Logger: homeassistant.components.automation.home_assistant_auto_update_on_a_schedule_base_4_00_5_00
Source: helpers/script.py:405
Integration: Автоматизация (documentation, issues)
First occurred: 05:00:10 (2 occurrences)
Last logged: 05:00:10

  • Home Assistant Auto-update on a schedule base: Repeat at step 9: 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
  • Home Assistant Auto-update on a schedule base: Error executing script. Error for repeat at pos 9: Error updating Home Assistant Operating System: ‘OSManager.update’ blocked from execution, system is not running - CoreState.FREEZE

Got the same error as SilverLeaf, on the upgrade of HAOS 8.5 to 9.0 during the night.

I have just tried to do the upgrade manually, and it was performed with no errors.

Thanks for sharing the error log.
Do you still haven’t updated or have you done that manually?
If you still on the old version I’d like to ask you to, before you update, to run the following under Developer Tools > Template and please let me know the results:

{% for u in integration_entities('hassio') | select('search', '^update[.]')
  if (device_attr(u, 'identifiers') | first)[1] == 'OS' %}
    {{ u }}
{% endfor %}

and:

{{ states.update | selectattr('state','eq','on') | map(attribute='entity_id') | list }}

Thanks in advance!!

I’ve updated the Blurprint in order to handle errors nicely.
I couldn’t test on my environment as I’m already updated, so I would appreciate if you can use this new Blueprint and provide your feedback.

Yes, I haven’t updated yet.

{% for u in integration_entities(‘hassio’) | select(‘search’, ‘^update[.]’)
if (device_attr(u, ‘identifiers’) | first)[1] == ‘OS’ %}
{{ u }}
{% endfor %}

results - update.home_assistant_operating_system_update

{{ states.update | selectattr(‘state’,‘eq’,‘on’) | map(attribute=‘entity_id’) | list }}

results-
[
“update.home_assistant_operating_system_update”,
“update.portainer_update”
]

After which I updated the Blurprint, I’ll see what happens tonight.

1 Like

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