fix: add unique_id to template yaml entities #368
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking change
If you have manually given any keymaster entities a unique_id in the keymaster yaml templates or generated yaml packages, this update will break after you regenerate the packages. If you have made any modifications to keymaster yaml, it is recommended to fully remove the keymaster integration and any manually altered entities before installing this update.
Proposed change
Assign each entity which uses the template platform a unique_id matching it's entity_id. This will allow users to hide these entities from the Home Assistant default UI.
Type of change
Additional information
This impacts binary_sensor, sensor, and lock domains.
Using entity_id as unique_id is designated as the id source of last resort in the HA developer documentation. However, since keymaster already assumes entity_id to be unique within the given HA instance, the impact of this is negligible.
Generating UUIDs on demand was considered and experimentally implemented. However, the need to maintain a separate registry of UUIDs led to too many edge cases. The proposed solution was selected for its simplicity and stability.
When combined with the additional search and filtering features of HA 2024.4, this makes it possible to hide all keymaster entities for a given lock by searching for your LOCKNAME in the entities list, selecting all, and then selecting hide. If LOCKNAME is not unique to keymaster, entities which share that string will need to be filtered out by the user.
The need for unique LOCKNAME strings could be addressed by prefixing all keymaster entities with "keymaster_". However, that would be a breaking change for all users and is therefore omitted in this PR.