Scheduled auto-update for Home Assistant

My apologies for the late reply here.

It could be that the automation started running while the schedule is on, but for some reason it takes too long to complete, to the point the schedule becomes off and this is a protection in the automation to prevents itself from run outside the time slot.
So we should understand why is the automation taking longer on this environment…

Can you see any error message related to updates (or this automation) on the Home Assistant logs (Settings > System > Logs)?

Hi @EdwardTFN

There’s nothing in the logs.

The updating should not take that long. I have already disabled the backup function, to see if it was hanging in a backup job. That did not help.

So, your recommendation would be to try and set the schedule to a longer time period? Say, 4-5 hours to be on the safe side?

It shouldn’t need all this time. Mine is set to 2h, but it rarely takes more than a few minutes.
Can you see which update entity is triggering the automation? Maybe that could help with the troubleshooting.

Hi @EdwardTFN

It’ still does not work. I’ve even tried to extend the schedule helper to a whole day.

It runs as it should though - but it doesn’t update anything, and the trace timeline and automation log is empty, so it’s hard to get clues.

Blueprint config

id: '1708087521465'
alias: Auto Update Home Assistant
description: ''
use_blueprint:
  path: edwardtfn/auto_update_scheduled.yaml
  input:
    schedule_entity: schedule.auto_update_schedule
    restart_bool: true
    backup_bool: false
    schedule_monthday: 6
    pause_entities:
      - input_boolean.auto_update_pause

The schedule helper triggered the automation, both when it turned on and when it turned off.
If you have somewhere, where I can look for further clues let me know :slight_smile:

I have the issue with at least two instances. Other instances does not seem to be affected.

A part from that the blueprint is solid.

Can you see anything related to this in the Logbook?

Hi @EdwardTFN , may I ask how long the script usually takes to update the system? I tried triggering script where there are two updates available (Home Assistant Core 2024.3.1 and Home Assistant Operating System 12.1), but the script finished instantly, and no change seems to be done to the system. Could you please help me figure out if anything is going wrong? Thank you!
Here are the logs:

Auto-update Done! triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update Running post-update actions... triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update 0 item(s) pending a restart: - triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update Remaining updates: - Home Assistant Core Update - Home Assistant Operating System Update triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update Finishing update process. triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update Variables: input_backup_bool: False, input_restart_bool: True, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 1, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.matter_server_update', 'update.nginx_proxy_manager_update', 'update.studio_code_server_update', 'update.silicon_labs_multiprotocol_update', 'update.onedrive_backup_update', 'update.network_ups_tools_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update'] triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update Variables: input_backup_bool: False, input_restart_bool: True, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 1, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.matter_server_update', 'update.nginx_proxy_manager_update', 'update.studio_code_server_update', 'update.silicon_labs_multiprotocol_update', 'update.onedrive_backup_update', 'update.network_ups_tools_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update'] triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update Variables: input_backup_bool: False, input_restart_bool: True, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 1, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.matter_server_update', 'update.nginx_proxy_manager_update', 'update.studio_code_server_update', 'update.silicon_labs_multiprotocol_update', 'update.onedrive_backup_update', 'update.network_ups_tools_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update'] triggered by automation Home Assistant Auto-update triggered
16:39:44 - 7 minutes ago
Auto-update Variables: input_backup_bool: False, input_restart_bool: True, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 1, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.matter_server_update', 'update.nginx_proxy_manager_update', 'update.studio_code_server_update', 'update.silicon_labs_multiprotocol_update', 'update.onedrive_backup_update', 'update.network_ups_tools_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update'] triggered by automation Home Assistant Auto-update triggered
16:39:43 - 7 minutes ago
Auto-update Running pre-update actions... triggered by automation Home Assistant Auto-update triggered
16:39:43 - 7 minutes ago
Auto-update List of updates: - Home Assistant Core Update - Home Assistant Operating System Update triggered by automation Home Assistant Auto-update triggered
16:39:43 - 7 minutes ago
Auto-update A new update is available for Home Assistant. triggered by automation Home Assistant Auto-update triggered
16:39:43 - 7 minutes ago
Auto-update Variables: input_backup_bool: False, input_restart_bool: True, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 1, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.matter_server_update', 'update.nginx_proxy_manager_update', 'update.studio_code_server_update', 'update.silicon_labs_multiprotocol_update', 'update.onedrive_backup_update', 'update.network_ups_tools_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update'] triggered by automation Home Assistant Auto-update triggered
16:39:43 - 7 minutes ago
Home Assistant Auto-update triggered
16:39:43 - 7 minutes ago - Traces

Hi - sorry for the delayed reply…

I can’t find anything in the HA log book. The automation traces tells me that no logs associated logs are available.

It’s weird because I manage 10-15 systems, and only a few of them has this issue. The rest updates juts fine.

Hi @EdwardTFN

I finally got some logs out.
I have this issue on 3 systems - the rest seems unaffected.

Can you make something out of the log?
From what I can see, it sees the available updates, but it doesn’t update them.

18 April 2024


DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
01:00:00 - Yesterday

Auto-update  Variables: input_backup_bool: True, input_restart_type: core, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 10, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.cloudflared_update', 'update.studio_code_server_update', 'update.weather_radar_card_update', 'update.anniversaries_update', 'update.horizon_card_update', 'update.mushroom_update', 'update.auto_entities_update', 'update.hacs_update', 'update.clock_weather_card_update', 'update.sonos_card_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update', 'update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
01:00:00 - Yesterday

Auto-update  A new update is available for Home Assistant. triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
01:00:00 - Yesterday

Auto-update  List of updates: - Home Assistant Core Update - Home Assistant Operating System Update - auto-entities update - Clock Weather Card update - Sonos Card update triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
01:00:00 - Yesterday

Auto-update  Running pre-update actions... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
01:00:00 - Yesterday

Auto-update  Backing up Home Assistant. triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
01:00:00 - Yesterday

Auto-update  Backup triggered. triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
01:00:08 - Yesterday

Auto-update  Variables: input_backup_bool: True, input_restart_type: core, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 10, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.cloudflared_update', 'update.studio_code_server_update', 'update.weather_radar_card_update', 'update.anniversaries_update', 'update.horizon_card_update', 'update.mushroom_update', 'update.auto_entities_update', 'update.hacs_update', 'update.clock_weather_card_update', 'update.sonos_card_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update', 'update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
02:00:08 - Yesterday

Auto-update  Starting sequence of standard updates... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
02:00:08 - Yesterday

Auto-update  Updating auto-entities update  of ['update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] ... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
02:00:08 - Yesterday

Auto-update  Starting sequence of standard updates... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
03:00:08 - Yesterday

Auto-update  Updating auto-entities update  of ['update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] ... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
03:00:08 - Yesterday

Auto-update  Starting sequence of standard updates... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
04:00:08 - Yesterday

Auto-update  Updating auto-entities update  of ['update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] ... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
04:00:08 - Yesterday

Auto-update  Starting sequence of standard updates... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
05:00:08 - Yesterday

Auto-update  Updating auto-entities update  of ['update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] ... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
05:00:08 - Yesterday

Auto-update  Starting sequence of standard updates... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
06:00:08 - Yesterday

Auto-update  Updating auto-entities update  of ['update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] ... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
06:00:08 - Yesterday

Auto-update  Variables: input_backup_bool: True, input_restart_type: core, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 10, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.cloudflared_update', 'update.studio_code_server_update', 'update.weather_radar_card_update', 'update.anniversaries_update', 'update.horizon_card_update', 'update.mushroom_update', 'update.auto_entities_update', 'update.hacs_update', 'update.clock_weather_card_update', 'update.sonos_card_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update', 'update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday

Auto-update  Variables: input_backup_bool: True, input_restart_type: core, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 10, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.cloudflared_update', 'update.studio_code_server_update', 'update.weather_radar_card_update', 'update.anniversaries_update', 'update.horizon_card_update', 'update.mushroom_update', 'update.auto_entities_update', 'update.hacs_update', 'update.clock_weather_card_update', 'update.sonos_card_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update', 'update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday

Auto-update  Variables: input_backup_bool: True, input_restart_type: core, input_verbose_logging_bool: True, input_max_backup_age_seconds: 0.0, input_schedule_monthday: 10, input_update_exclusions: [[], []], input_core_os_update_mode: all, input_firmware_update_mode: all, input_general_update_mode: all, core_update_entity: update.home_assistant_core_update, os_update_entity: update.home_assistant_operating_system_update, supervisor_update_entity: update.home_assistant_supervisor_update, firmware_update_entities: [], general_update_entities; ['update.cloudflared_update', 'update.studio_code_server_update', 'update.weather_radar_card_update', 'update.anniversaries_update', 'update.horizon_card_update', 'update.mushroom_update', 'update.auto_entities_update', 'update.hacs_update', 'update.clock_weather_card_update', 'update.sonos_card_update'], updates_list: ['update.home_assistant_core_update', 'update.home_assistant_operating_system_update', 'update.auto_entities_update', 'update.clock_weather_card_update', 'update.sonos_card_update'] triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday

Auto-update  Finishing update process. triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday

Auto-update  Remaining updates: - Home Assistant Core Update - Home Assistant Operating System Update - auto-entities update - Clock Weather Card update - Sonos Card update triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday

Auto-update  0 item(s) pending a restart: - triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday

Auto-update  Running post-update actions... triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday

Auto-update  Done! triggered by automation DO NOT EDIT - Auto Update Home Assistant  triggered by state of Run Auto Update
07:00:08 - Yesterday


Not that much. :frowning:
I will try to review the code and add more useful logs.

Thank you,

If you tell me where to look - I’ll see if I can get better logs for you.

There is…
Looks like it is breaking between the pre-update actions and the backup, so I have a few questions here:

  1. Do you have any action set under “(optional) Pre-update actions”? If not, could you please set a simple action, like turn-off a light, just for test, and let me know if that action is executed? And please let me know if the update ran after an action was set.
  2. Do you have a sensor named sensor.backup_state? If so, could you please go to Developer Tools, under the tab “States” and share here its state and attributes. I’m interested only on the attributes keys available, so no need to share it’s values, if you can/want hide those.

Thanks for this - just set it up and I’d like to test it (currently have 8 updates sitting ready to install)

If I hit “run” the blueprint, it doesn’t seem to do anything - I am inside the schedule I’ve created (specifically created to test)
Am I missing something or will it just run at a random time within the period?

Hi @EdwardTFN

Sorry for the delay in response.

  1. No, nothing is set here
  2. No such sensor exists on any of the systems I run

Step detail, and where it seems to fail:

TL; DR;
To do a manual test run, make sure the “create full backup” is not on, or alternatively, start your manual test, wait about 1hr and 20 minutes and check back, things should be updated.

Longer version:
I was on this same boat and I realized it is because you likely have the “create full backup” toggled ON. If you do, there’s an artificial delay of 1hr HomeAssistant-Config/blueprints/automation/EdwardTFN/auto_update_scheduled.yaml at 7605a7b216ca50545882c7d6066c67791de2ee90 · edwardtfn/HomeAssistant-Config · GitHub because there’s no other way to tell if the backup has been completed.

This is not a problem when it is running as intended (scheduled) as you wouldn’t notice. But you and me wanted to test-run it ourselves and saw it “hanging” because of it. Toggle the create backup off and it will start a new run since one of the triggers is that the automation is reloaded.

Don’t forget to re-enable the full backup after you’ve manually tested

Since ESPHome 2024.6, this automation seems to be unable to update ESPhome devices now. When I look in the logbook entries when it runs, I see that it identifies the devices as needing an update, but then I never see an entry in the logbook for actually cycling through to update them.

If I manually click the Install button for a firmware update within Home Assistant for an ESPHome device, it updates fine.

Nevermind…for whatever reason, after making that post it updated on its own overnight, despite not working for the last few weeks :man_shrugging:t2:

1 Like

I have to work on this Blueprint to call for a refresh on ESPHome devices after ESPHome is updated, otherwise it won’t happens until the schedule is triggered again. :weary:

@EdwardTFN would it be possible for this template to have a condition for devices such as power monitoring ‘plugs’, that have a relay that sees them momentarily turn off the power to anything connected to the plug… such as “if plugs Power / Active Power is not 0W, then don’t update” ?

This would allow being able to run an update for all those esphome devices that aren’t plugs or are plugs, but don’t have anything powered up and be able to avoid crashing PCs / devices connected to these plugs if the ‘update all’ option is used.

Thanks.

In fact you can achieve this with the current implementation by creating a template binary sensor which will be true when the power is above a threshold (1W?) and use this sensor as the “pause” entity for your update automation (the one using the blueprint), so the update won’t run unless that sensor is false.
You can have multiple instances of this blueprint sharing the same schedule entity and each one driving distinct updates, so you will be able to have only those devices updating based on the power, while everything else updates based on the schedule.