HA Core auto update Patch version

Auto update Home Assistant when a new patch release is available

We all know that auto updating is not a good idea because of the breaking changes. The patch versions however should not contain any breaking changes.

So when the update.home_assistant_core_update turns on, we can fire an automation, then check if only the patch version has increased. If so, then proceed with the update.

Here is the template for the condition:

{% set current_version = state_attr('update.home_assistant_core_update', 'installed_version').split('.') %}
{% set latest_version = state_attr('update.home_assistant_core_update', 'latest_version').split('.') %}

{% if current_version | length == 3 and
      latest_version | length == 3 and
      current_version[0] == latest_version[0] and
      current_version[1] == latest_version[1] and
      current_version[2] < latest_version[2] %}
    true
{% else %}
    false
{% endif %}

And here is the action:

action: update.install
metadata: {}
data:
  backup: true
target:
  entity_id: update.home_assistant_core_update

Add some nice notifications as a bonus (of course the notifs should come first before the update step, if you add them):

action: notify.mobile_app_somebody
metadata: {}
data:
  title: Updating Home Assistant
  message: >-
    From:
    {{state_attr('update.home_assistant_core_update','installed_version')}}

    To: {{state_attr('update.home_assistant_core_update','latest_version')}}

And

action: persistent_notification.create
metadata: {}
data:
  title: Updating Home Assistant!
  message: >-
    ##
    {{state_attr('update.home_assistant_core_update','installed_version')}}     
    > {{state_attr('update.home_assistant_core_update','latest_version')}} 

    **At:** {{ as_timestamp(now()) | timestamp_custom('%A, %Y %B %-d, %H:%M') }}

Let me know if you have ideas for improvement.
Cheers

1 Like