Update
The update integration shows what can be updated in Home Assistant: its apps, integrations from HACS, the firmware of devices. Each as an update entity, on when there is an update waiting.
Home Assistant's own install action is made for one update at a time, though. Aim it at a label or at everything, and one update in it that is up to date fails the whole call. Aim it at an area or a device, and it passes over the updates in it altogether: those only bring their main entities along, and an update entity is a configuration or diagnostic entity. And the release notes the update dialog shows are out of reach for an automation.
Spook adds two actions for that: install everything that has an update, and get the release notes.
Actions
Spook adds two actions to the update integration. You find them wherever you add an action, marked with a 👻. Both are for administrators only, as Home Assistant's own install and its release notes are.
Install all updates
Installs every update in the target that has one. One at a time, sorted by entity ID, so the same call goes the same way every time.
The target is any action target: update entities, devices, areas, floors and labels, with an exclude. An area or a device brings its update entities along. In YAML, entity_id: all is every update there is.
Each install goes through Home Assistant's own install action, with its own checks. What has nothing to install is skipped, not an error:
- An update that is up to date, or whose latest version you skipped.
- An update that is being installed right now.
- An update that is unavailable, or does not know its versions.
- An update that only tells a new version is out, and cannot be installed from Home Assistant.
The updates of Home Assistant itself, its operating system and the Supervisor are always skipped. They restart Home Assistant or the machine halfway, which would cut the action off with the rest still to do. Install those on the updates page, or with Home Assistant's own install action, last. Spook recognizes them by what the Supervisor integration made, so renaming their entity IDs does not change that. Apps are installed like any other update.
With Backup on, every update that can make a backup first does. The others install without one, and the response says which got a backup.
One install failing does not stop the rest. What happens next depends on whether you ask for the response:
- With a response variable, nothing is raised. The response lists what was installed, what failed and why, and what was skipped and why. Check it in your automation.
- Without one, nobody would see a failure. So once everything else had its turn, the action fails with an error that names each update that failed, and why.
A target without a single update entity is refused with an error.
How to use it
- Open the automation or script that should install the updates, and select Add action.
- Search for install all, and select Update: Install all updates 👻.
- Under Targets, choose the updates, like a label you gave them.
- Turn on Backup if you want a backup before each install.
- Select Save.
| Action properties | |
|---|---|
| Action | Update: Install all updates 👻 |
| Action name | update.install_all |
| Action targets | Yes, update entities |
| Action response | Optional, what was installed, what failed and what was skipped |
| Spook's influence | Newly added action |
| Tools | Try this action |
| Action data parameters | |||
|---|---|---|---|
| Attribute | Type | Required | Default / Example |
backup | boolean | No | false |
The response:
| Attribute | Type | Description |
|---|---|---|
installed | list | The updates installed, in the order they were installed. |
installed[].entity_id | string | The update entity. |
installed[].from_version | string | The version installed before. |
installed[].to_version | string | The version it installed. |
installed[].backup | boolean | Whether it made a backup first. |
failed | list | The updates that failed to install. |
failed[].entity_id | string | The update entity. |
failed[].error | string | Why it failed, as the update said it. |
skipped | list | The updates that were not installed. |
skipped[].entity_id | string | The update entity. |
skipped[].reason | string | Why it was not installed, one of the reasons below. |
The reasons an update is skipped:
up_to_date: there is nothing newer to install.skipped_version: the latest version is skipped.in_progress: it is being installed right now.unavailable: the update entity is unavailable.unknown: the update does not know its installed or latest version.cannot_install: it cannot be installed from Home Assistant.home_assistant: it updates Home Assistant itself, its operating system or the Supervisor.
Every night, install every update with the label nightly, with a backup first where it can, and get a notification for what failed:
triggers:
- trigger: time
at: "03:00:00"
actions:
- action: update.install_all
target:
label_id: nightly
data:
backup: true
response_variable: result
- if:
- condition: template
value_template: "{{ result.failed | count > 0 }}"
then:
- action: notify.persistent_notification
data:
title: Not every update installed
message: >-
{% for failure in result.failed %}
{{ failure.entity_id }}: {{ failure.error }}
{% endfor %}
Install everything that has an update, and let the automation fail when one of them does:
action: update.install_all
target:
entity_id: all
- Installed means the install finished without an error. Some devices only take the request, and install in their own time. Those report the new version later.
- The installs run one after the other, and the action waits for all of them. A long list of firmware updates can take a while.
- An update that needs a restart of Home Assistant to count says so on the updates page. The action never restarts anything.
Get release notes
Gets the release notes of one or more updates: the full ones the update dialog shows, with the installed and latest version, the short summary and the link to the release. To read before installing, or to send along in a notification.
The target is any action target, like for Install all updates. The response holds every update entity in it, under its entity ID.
Not every update has full release notes. Those get the summary and the link, and no notes. An update that is unavailable is not asked, and the response says it is not available. Release notes are often fetched from the internet: when that fails for one update, its error says why, and the others are still there.
How to use it
- Open the automation or script that needs the release notes, and select Add action.
- Search for release notes, and select Update: Get release notes 👻.
- Under Targets, choose the updates.
- Under Response variable, give the release notes a name, like
notes. The steps after this one can use it. - Select Save.
| Action properties | |
|---|---|
| Action | Update: Get release notes 👻 |
| Action name | update.get_release_notes |
| Action targets | Yes, update entities |
| Action response | Yes, the release notes of every update in the target |
| Spook's influence | Newly added action |
| Tools | Try this action |
This action takes no data, only a target.
The response holds one entry per update entity, under its entity ID:
| Attribute | Type | Description |
|---|---|---|
available | boolean | Whether the update could be asked. false for one that is unavailable. |
installed_version | string or null | The version installed. |
latest_version | string or null | The latest version out. |
release_summary | string or null | The short summary of the release, null when the update has none. |
release_url | string or null | The link to the release, null when the update has none. |
release_notes | string or null | The full release notes, in Markdown. null for an update without them, or when they failed to come. |
error | string or null | Why the release notes could not be fetched. null when nothing went wrong. |
Get a notification with what changed, when an update for the firmware of the router comes out:
triggers:
- trigger: state
entity_id: update.router_firmware
to: "on"
actions:
- action: update.get_release_notes
target:
entity_id: update.router_firmware
response_variable: notes
- action: notify.persistent_notification
data:
title: >-
Router firmware {{ notes['update.router_firmware'].latest_version }}
message: >-
{{ notes['update.router_firmware'].release_notes
or notes['update.router_firmware'].release_summary
or 'No release notes.' }}
Missing something here?
An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.
