Home Assistant: Aggiornamenti automatici per semplificare la gestione del sistema
Scopri come gli aggiornamenti automatici per Home Assistant possono semplificare la gestione del tuo sistema domotico, gestendo backup, notifiche
La sfida degli aggiornamenti manuali
Gestire un sistema domotico come Home Assistant richiede attenzione costante, soprattutto per quanto riguarda gli aggiornamenti. Mantenere il software aggiornato è fondamentale per garantire sicurezza, stabilità e l'accesso alle ultime funzionalità. Tuttavia, il processo di aggiornamento manuale può diventare oneroso, richiedendo tempo e la necessità di monitorare attivamente la disponibilità di nuove versioni. Questo può portare a trascurare aggiornamenti importanti, esponendo il sistema a potenziali vulnerabilità o limitando l'esperienza utente. La paura di un aggiornamento fallito o di un'interruzione del servizio spinge molti utenti a rimandare, creando un accumulo di aggiornamenti che rende il processo ancora più complesso.
Aggiornamenti automatici per Home Assistant
La gestione degli aggiornamenti di Home Assistant può essere semplificata grazie a soluzioni automatizzate. Il blueprint Advanced Auto-Updater offre una gestione sicura e personalizzabile degli aggiornamenti, riducendo la necessità di interventi manuali e garantendo che il sistema rimanga sempre all'ultima versione stabile.
Il Blueprint Advanced Auto-Updater
Aggiornamenti automatici Home Assistant - Per ovviare a queste problematiche, è stato sviluppato il blueprint Advanced Auto-Updater, una soluzione pensata per automatizzare il processo di aggiornamento di Home Assistant. Questo strumento non si limita a installare le nuove versioni, ma gestisce l'intero ciclo in modo intelligente e sicuro. Il suo scopo principale è liberare gli utenti dalla preoccupazione di dover controllare e installare manualmente ogni aggiornamento, garantendo al contempo la stabilità del sistema.
Funzionalità chiave del blueprint
L'Advanced Auto-Updater offre una serie di funzionalità avanzate per rendere l'automazione degli aggiornamenti il più robusta possibile. Tra queste spiccano la gestione intelligente delle riprese in caso di interruzioni (smart Resume), la possibilità di eseguire backup automatici prima di ogni aggiornamento e notifiche finali precise. Il sistema è in grado di gestire diversi tipi di aggiornamenti, inclusi quelli relativi ai componenti core di Home Assistant, al Supervisor, al sistema operativo, agli add-on e alle integrazioni HACS. La versione 5.3.0 ha rimosso il backup per-update, optando per un unico backup completo prima dell'avvio, migliorando la compatibilità con integrazioni come Afvalbeheer e ottimizzando lo spazio su disco. Le versioni precedenti hanno introdotto logging dettagliato degli errori, supporto per servizi di notifica moderni come Telegram e una gestione più robusta dei timeout di installazione.
Configurazione e personalizzazione
La configurazione del blueprint è estremamente flessibile, permettendo agli utenti di personalizzare il comportamento dell'aggiornamento automatico in base alle proprie esigenze. È possibile definire l'orario di esecuzione giornaliero, selezionare i giorni della settimana in cui gli aggiornamenti sono permessi, e decidere se creare un backup completo prima dell'installazione. Gli utenti possono inoltre specificare quali tipi di aggiornamenti automatizzare (add-on, HACS, OS/Supervisor, Core) e impostare il numero massimo di tentativi di riprova in caso di fallimento. Sono previsti timeout personalizzabili sia per il backup che per l'installazione degli aggiornamenti. Per una gestione più avanzata, è possibile integrare helper di tipo input_text e input_boolean per monitorare lo stato dell'aggiornamento e la sua progressione.
Gestione dei backup e notifiche
Un aspetto cruciale dell'automazione degli aggiornamenti è la gestione dei backup. Il blueprint Advanced Auto-Updater permette di configurare la creazione di un backup completo di Home Assistant prima che venga avviato qualsiasi processo di aggiornamento. Questo garantisce un punto di ripristino sicuro in caso di problemi imprevisti. Le notifiche sono altrettanto importanti: il sistema può inviare avvisi dettagliati al termine del processo, informando l'utente sull'esito dell'aggiornamento, inclusi eventuali errori o dettagli sulle versioni installate. È possibile utilizzare sia i servizi di notifica legacy (notify.*) sia quelli più moderni come notify.send_message, offrendo ampia compatibilità con i sistemi di notifica esistenti, come Telegram.

Conclusioni: un passo avanti per la domotica
L'introduzione di soluzioni come il blueprint Advanced Auto-Updater rappresenta un significativo passo avanti per la gestione dei sistemi domotici basati su Home Assistant. Automatizzare gli aggiornamenti non solo semplifica la vita degli utenti, ma contribuisce anche a mantenere il sistema più sicuro e stabile nel tempo. La flessibilità di configurazione e le robuste funzionalità di backup e notifica rendono questo strumento una risorsa preziosa per chiunque desideri ottimizzare la gestione della propria smart home. L'adozione di aggiornamenti automatici Home Assistant ben configurati permette di concentrarsi maggiormente sull'utilizzo e sull'espansione del proprio ecosistema domotico, piuttosto che sulla sua manutenzione ordinaria.
blueprint:
name: Advanced Auto-Updater
description: >-
Automatically installs updates based on your toggles. Smartly sequences
updates, survives HA restarts, retries failed downloads, and sends exactly
ONE final notification.
Version: 5.3.0
### Changelog
* 5.3.0: Removed per-update backup (backup: true). Only one full backup
is created before the update run. This fixes "Backup is not supported"
errors for HACS integrations like Afvalbeheer and saves disk space.
* 5.2.0: Added detailed failure reason logging to system_log with level
error. Failed updates now log entity state, installed/latest version, and
timeout info. Uses logger
homeassistant.components.automation.advanced_auto_updater for easy
filtering.
* 5.1.0: Added optional notify.send_message support for modern
notification services (e.g. Telegram). Both legacy notify and
send_message can be used simultaneously.
* 5.0.2: Removed deprecated sensor.backup_manager_state. Backup is now
treated as blocking (hassio.backup_full is synchronous).
* 5.0.1: Moved release URLs to the final notification to avoid the
255-character log limit.
* 5.0.0: Added optional pre-run backup, release notes in notifications,
and day-of-week filtering.
* 4.1.1: Robustness fixes for state handling, log truncation, and entity
filtering.
* 4.1.0: Fixed install_timeout to use minutes instead of a time-of-day
selector.
* 4.0.0: Major robustness improvements for resume handling and
notifications.
* 3.0.0: Major refactor with all review improvements applied.
domain: automation
source_url: https://gist.github.com/Artropos/0b8ada3459b10e4d3bbf259ea71c3ace
input:
run_time:
name: Scheduled time
description: Time at which updates should run daily.
default: 03:00:00
selector:
time: {}
allowed_days:
name: Update days
description: 'On which days of the week is the update run allowed to start?'
default:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
selector:
select:
options:
- label: Monday
value: mon
- label: Tuesday
value: tue
- label: Wednesday
value: wed
- label: Thursday
value: thu
- label: Friday
value: fri
- label: Saturday
value: sat
- label: Sunday
value: sun
multiple: true
mode: list
sort: false
custom_value: false
create_backup_before_run:
name: Create full backup before update run
description: 'Create a full Home Assistant backup before the first update is installed.'
default: true
selector:
boolean: {}
backup_timeout:
name: Backup timeout (minutes)
description: Maximum time in minutes to wait for the pre-run backup to complete.
default: 30
selector:
number:
min: 10.0
max: 120.0
step: 5.0
unit_of_measurement: minutes
mode: slider
notification_service:
name: "Legacy notification service(s) (notify.* actions)"
description: 'Enter one or more legacy notify services, separated by commas.'
default: ''
selector:
text:
multiline: false
multiple: false
send_message_targets:
name: "Modern notification service(s) (notify.send_message)"
description: 'Select one or more notification service entities.'
default: []
selector:
entity:
domain:
- notify
multiple: true
update_addons:
name: Update Add-ons
description: Automatically install Supervisor add-on updates.
default: true
selector:
boolean: {}
update_hacs:
name: Update HACS & Integrations
description: Automatically install HACS and custom integration updates.
default: true
selector:
boolean: {}
update_os:
name: Update OS & Supervisor
description: 'Automatically install Home Assistant OS and Supervisor updates.'
default: true
selector:
boolean: {}
update_core:
name: Update Home Assistant Core
description: 'Automatically install Core updates.'
default: false
selector:
boolean: {}
max_retries:
name: Maximum retries
description: Maximum number of retry attempts for failed updates before giving up.
default: 3
selector:
number:
min: 1.0
max: 10.0
step: 1.0
mode: slider
install_timeout:
name: Install timeout (minutes)
description: Maximum time in minutes to wait for a single update to complete.
default: 30
selector:
number:
min: 5.0
max: 120.0
step: 5.0
unit_of_measurement: minutes
mode: slider
log_entity:
name: Update log helper
description: 'Select an input_text helper used to store the update log during a run.'
selector:
entity:
domain:
- input_text
multiple: false
stage_entity:
name: Stage helper
description: 'Select an input_text helper used to track the current update stage.'
selector:
entity:
domain:
- input_text
multiple: false
run_active_helper:
name: Run active helper
description: 'Select an input_boolean that tracks whether an update run is currently in progress.'
selector:
entity:
domain:
- input_boolean
multiple: false
notification_sent_helper:
name: Notification sent helper
description: 'Select an input_boolean that tracks whether the final notification has been sent.'
selector:
entity:
domain:
- input_boolean
multiple: false
mode: single
max_exceeded: silent
trigger:
- platform: time
at: !input run_time
id: scheduled
- platform: homeassistant
event: start
id: startup
variables:
raw_notify_service: !input notification_service
notify_list: >-
{% set ns = namespace(items=[]) %}
{% for item in raw_notify_service.split(',') %}
{% set svc = item | trim %}
{% if svc != '' %}
{% set ns.items = ns.items + [svc] %}
{% endif %}
{% endfor %}
{{ ns.items }}
send_message_targets: !input send_message_targets
update_addons: !input update_addons
update_hacs: !input update_hacs
update_os: !input update_os
update_core: !input update_core
max_retries: !input max_retries
install_timeout: !input install_timeout
log_entity: !input log_entity
stage_entity: !input stage_entity
run_active_helper: !input run_active_helper
notification_sent_helper: !input notification_sent_helper
allowed_days: !input allowed_days
create_backup_before_run: !input create_backup_before_run
backup_timeout: !input backup_timeout
condition:
- condition: template
value_template: >-
{% set run_active = is_state(run_active_helper, 'on') %}
{% set notif_sent = is_state(notification_sent_helper, 'on') %}
{% if trigger.id == 'scheduled' %}
{% set day_ok = now().strftime('%a') | lower in allowed_days %}
{% if not day_ok %}
false
{% else %}
{% set hacs_ids = integration_entities('hacs') | select('match', '^update\.') | list %}
{% set supervisor_updates = integration_entities('hassio') | select('match', '^update\.') | list %}
{% set excluded = [
'update.home_assistant_core_update',
'update.home_assistant_operating_system_update',
'update.home_assistant_supervisor_update'
] %}
{% set addon_ids = supervisor_updates | reject('in', hacs_ids) | reject('in', excluded) | list %}
{% set os_ids = [
'update.home_assistant_supervisor_update',
'update.home_assistant_operating_system_update'
] %}
{% set core_ids = ['update.home_assistant_core_update'] %}
{% set ns = namespace(pending=false) %}
{% for e in states.update | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list %}
{% if update_addons and e in addon_ids %}
{% set ns.pending = true %}
{% elif update_hacs and e in hacs_ids %}
{% set ns.pending = true %}
{% elif update_os and e in os_ids %}
{% set ns.pending = true %}
{% elif update_core and e in core_ids %}
{% set ns.pending = true %}
{% endif %}
{% endfor %}
{{ ns.pending and not run_active }}
{% endif %}
{% elif trigger.id == 'startup' %}
{{ run_active and not notif_sent }}
{% else %}
false
{% endif %}
action:
# --- Scheduled: reset helpers ---
- if:
- condition: trigger
id: scheduled
then:
- action: input_text.set_value
data:
entity_id: !input log_entity
value: ''
- action: input_text.set_value
data:
entity_id: !input stage_entity
value: idle
- action: input_boolean.turn_on
data:
entity_id: !input run_active_helper
- action: input_boolean.turn_off
data:
entity_id: !input notification_sent_helper
- delay: 00:00:01
# --- Startup: wait for entities ---
- if:
- condition: trigger
id: startup
then:
- wait_template: >-
{{ states(log_entity) not in ['unknown', 'unavailable']
and states(stage_entity) not in ['unknown', 'unavailable']
and states(run_active_helper) not in ['unknown', 'unavailable']
and states(notification_sent_helper) not in ['unknown', 'unavailable'] }}
timeout: 00:10:00
continue_on_timeout: false
- delay: 00:02:00
# --- Compute entity lists ---
- variables:
hacs_entities: >-
{{ integration_entities('hacs')
| select('match', '^update\.')
| list }}
addon_entities: >-
{% set hacs_ids = integration_entities('hacs') | select('match', '^update\.') | list %}
{% set excluded = [
'update.home_assistant_core_update',
'update.home_assistant_operating_system_update',
'update.home_assistant_supervisor_update'
] %}
{{ integration_entities('hassio')
| select('match', '^update\.')
| reject('in', hacs_ids)
| reject('in', excluded)
| list }}
safe_log: >-
{% set log = states(log_entity) %}
{{ '' if log in ['unknown', 'unavailable', 'none', ''] else log }}
current_stage: >-
{% set s = states(stage_entity) %}
{{ '' if s in ['unknown', 'unavailable', 'none', ''] else s }}
current_selected_updates: >-
{% set ns = namespace(items=[]) %}
{% set hacs_ids = integration_entities('hacs') | select('match', '^update\.') | list %}
{% set excluded = [
'update.home_assistant_core_update',
'update.home_assistant_operating_system_update',
'update.home_assistant_supervisor_update'
] %}
{% set addon_ids = integration_entities('hassio')
| select('match', '^update\.')
| reject('in', hacs_ids)
| reject('in', excluded)
| list %}
{% set os_ids = [
'update.home_assistant_supervisor_update',
'update.home_assistant_operating_system_update'
] %}
{% set core_ids = ['update.home_assistant_core_update'] %}
{% for e in states.update | selectattr('state', 'eq', 'on') | map(attribute='entity_id') | list %}
{% if update_addons and e in addon_ids %}
{% set ns.items = ns.items + [e] %}
{% elif update_hacs and e in hacs_ids %}
{% set ns.items = ns.items + [e] %}
{% elif update_os and e in os_ids %}
{% set ns.items = ns.items + [e] %}
{% elif update_core and e in core_ids %}
{% set ns.items = ns.items + [e] %}
{% endif %}
{% endfor %}
{{ ns.items }}
# --- Guard: stuck state ---
- if:
- condition: template
value_template: >-
{{ is_state(run_active_helper, 'on')
and is_state(notification_sent_helper, 'on')
and current_stage in ['idle', ''] }}
then:
- action: input_boolean.turn_off
data:
entity_id: !input run_active_helper
- action: input_boolean.turn_off
data:
entity_id: !input notification_sent_helper
- action: input_text.set_value
data:
entity_id: !input log_entity
value: ''
- action: input_text.set_value
data:
entity_id: !input stage_entity
value: idle
- action: system_log.write
data:
message: >-
Auto-updater: Stuck run state detected and cleared
(run_active=on, notification_sent=on, stage=idle).
level: warning
- stop: Stuck run state cleared.
# --- Guard: stale state ---
- if:
- condition: template
value_template: >-
{{ is_state(run_active_helper, 'on')
and is_state(notification_sent_helper, 'off')
and (current_selected_updates | count == 0)
and (safe_log | trim == '')
and current_stage in ['idle', ''] }}
then:
- action: input_boolean.turn_off
data:
entity_id: !input run_active_helper
- action: input_boolean.turn_off
data:
entity_id: !input notification_sent_helper
- action: input_text.set_value
data:
entity_id: !input log_entity
value: ''
- action: input_text.set_value
data:
entity_id: !input stage_entity
value: idle
Commenti
Ancora nessun commento. Sii il primo a partecipare.