Replies: 2 comments 5 replies
-
One thing which doesn't seem covered which i think is important is deleted scripts/automations. There i times when i delete an automation after refactoring more into one and then wanting to go back to a previous snapshot. |
Beta Was this translation helpful? Give feedback.
4 replies
-
We should always store things based on their |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
Currently it is not possible for a user to easily revert an automation/script to a specific version/time after tinkering with it. This leads to a big use case for the backups, unpack the backup and restore a automation/script by copying and pasting the YAML. Which in turn leads to a major pain point with encrypted backups, you can't easily unpack them without an extra step.
Which all together makes it difficult for a non-technical user to revert an automation/script to a specific version/time.
Proposal
To solve this, my proposal would be a new history manager. This manager would store x entries (maybe configurable) of the last changes made to each automation/script via the UI. The version would be appended to a list, hold by the manager, each time it is saved via the UI.
The history manager would make use of the existing
Store
class like our other registries. The history manager holds aStore
for each domain e.g.automation
orscript
, which would result in a storage file for each domain e.g.core.automation_history
to avoid one large JSON file. Each history entry will hold a reference to the related script/automation by itsunique_id
. Each history entry can be identified by its ownentry_id
.Deletion & Orphaned history entries
Upon automation/script deletion the history manager will store the last entry with a deletion timestamp. Orphaned history entries will be stored for 30 days after deletion of the related automation/script.
Websocket API
List history entries
A new Websocket API would allow the frontend to request a list of all entries for a particular automation/script from the manager:
Request
Response
Retrieve config
A second Websocket API would allow the frontend to request the actual configuration for an entry in the history, to avoid sending a large chunk of data via the
list
endpoint to the frontend.Request
Response
Would return the actual stored config (saved by the frontend), which can be used by the frontend directly, e.g.:
List deleted
A third websocket API would allow the frontend to display a list of deleted automations/scripts. This endpoint would only send the last history entry.
Request
Response
Final words
The frontend would then provide a list of the existing version in the history manager. The user would then load the specific entry for that time, review it and decide if they want to save/restore it.
This would give us a simple and user-friendly way to restore an automation/script without having to decrypt or restore a full backup, which could be used in other parts of Home Assistant.
Quick PoC
Bildschirmaufnahme.2025-01-19.um.18.06.11.mov
Changes
2025-01-19: Added restore of deleted automation/script
2025-01-19: Replace
key
withunique_id
Beta Was this translation helpful? Give feedback.
All reactions