If you normally make a backup of an Add-on before upgrading it, you might be interested in the following application that simplifies the process. 1
1. Create Template entities
Create the following Template Select and Trigger-based Template Sensor entities. The select
entity will automatically populate itself with the names of add_ons associated with the Supervisor integration.
select.add_ons, sensor.add_ons_selection
template:
- trigger:
- platform: event
event_type: custom_add_ons_selection
sensor:
- name: Add Ons Selection
unique_id: custom_add_ons_selection_helper
state: "{{ trigger.event.data.value }}"
- select:
- name: "Add Ons"
state: "{{ states('sensor.add_ons_selection') }}"
options: >
{% set x = integration_entities('Supervisor')
| select('match', 'update')
| reject('match', 'update\.home_assistant')
| list %}
{% set z = zip(x | map('device_attr', 'name') | list,
x | map('device_attr', 'name_by_user') | list) | list %}
{{ (z | select('contains', none) | map(attribute=0) | list
+ z | reject('contains', none) | map(attribute=1) | list)
| sort }}
select_option:
- event: custom_add_ons_selection
event_data:
value: "{{ option }}"
2. Create script
Create the following script.
script.backup_add_on
backup_add_on:
alias: Backup Add On
description: Backup selected add-on
mode: single
sequence:
- variables:
id: "{{ device_id(states('select.add_ons')) }}"
- if: "{{ id is not none }}"
then:
- variables:
add_on: "{{ (device_attr(id, 'identifiers') | list)[0][1] }}"
label: >
{{ "addon_{}_{}_{}".format(
(device_attr(id, 'identifiers') | list)[0][1],
device_attr(id, 'sw_version'),
(now() | string)[:-13]) }}
- action: hassio.backup_partial
data:
homeassistant_exclude_database: true
compressed: true
addons: "{{ add_on }}"
name: "{{ label }}"
else:
- action: notify.persistent_notification
data:
title: Invalid Add-On Selection
message: The selected add-on does not exist.
3. Create cards
Create the UI with an Entities Card and a Button Card. The following example puts the two cards within a Vertical Stack card but youāre free to arrange them in whatever way you prefer.
Cards
type: vertical-stack
cards:
- type: entities
entities:
- entity: select.add_ons
- show_name: true
show_icon: false
type: button
tap_action:
action: toggle
entity: script.backup_add_on
Usage
To backup an Add-on, select the desired Add-on from select.add_ons
then click the āBackup Add Onā button. The resulting backup will be labeled in this format:
addon_a0d7b954_nodered_18.1.1_2025-01-09 10:07:55
Please be advised that I have not yet tested this in version 2025.1.X. You shouldnāt encounter any problems but if you do, I wonāt be able to fix them until the end of January (when I plan to upgrade to 2025.1.X).
Footnotes
- As of version 2025.1.1, the backup toggle button has been removed from the Update panel. It eliminates the convenience of optionally creating a backup of the Add-on prior to upgrading it. The current alternative is to use
hassio.backup_partial
(in a script or in Developer Tools ā Actions).
Versions
2025-01-15 Supports renamed Add-ons.
The Template Select in the initial version listed each Add-onās default name. If the user changed the Add-onās name, it wasnāt shown in the Template Select. As a consequence, the script failed to find the Add-on (because it searched using the default name).
In this version, the Template Select lists an Add-onās modified name (if the user modified it, otherwise it shows the default name).