Allow Home Assistant to regenerate entity IDs - #1825
Closed
sargant wants to merge 3 commits into
Closed
Conversation
sargant
marked this pull request as ready for review
August 17, 2026 20:35
3 tasks
sargant
force-pushed
the
allow-home-assistant-entity-ids
branch
from
August 17, 2026 20:52
a95dd21 to
be2bd34
Compare
Author
|
I could conceivably do this across the rest of the codebase for all exposed entities with dynamic names, if it would make sense for a single potentially breaking change. Felt it was too much for a single PR though. |
Author
|
Closed - will continue work in https://github.com/sargant/HomeAssistant-OctopusEnergy/tree/adopt-ha-entity-naming in the short term |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements #1821 by allowing Home Assistant to generate entity IDs for electricity and gas meter entities instead of explicitly generating them from
unique_id. This brings the meters in line with the recommended entity naming scheme wherehas_entity_name=True.Meter identity now lives on the device (
Octopus Energy Electricity/Gas (<serial>/<MPAN/MPRN>)), while entity names keep their existing human-readable wording with that device context removed. Existing installs keep their current entity IDs because the underlyingunique_ids are unchanged. New entities, or entities explicitly recreated with Home Assistant’s Recreate entity IDs action, use the user's configured entity ID format set in Home Assistant's settings.For existing unrenamed meter devices, the integration-provided device name is updated to include the serial and MPAN/MPRN, so recreated IDs generally retain those identifiers and remain the same. User-renamed devices continue to respect the user’s chosen device name, and so may omit the MPAN/MPRN when regenerated.
Recreated IDs generally match the existing IDs. One known exception is
previous_consumption_rates_data_last_retrieved, whose historical entity ID omitted the wordandeven though the human-readable entity name has always been “Previous Consumption and Rates Data Last Retrieved”. Recreating that entity therefore producesprevious_consumption_and_rates_data_last_retrieved.This means recreating entity IDs can be a breaking action: users who have renamed meter devices may get differently structured IDs, and the entity above will always change. Nothing changes for users who simply upgrade and leave their existing entity IDs alone.
This is deliberately scoped to electricity/gas meter entities; other entity families retain the existing explicit ID generation. I'll raise a second PR with the more wide-ranging changes for all devices and entities exposed by the integration - however I only have a gas & electricity meter and an Octopus Home Mini personally, so this is all I can test.
Includes tests for new HA-generated IDs, preservation of existing registered IDs, export/name ordering, meter diagnostics, and legacy Octoplus behaviour.
AI assistance disclosure: I used Codex/ChatGPT to help implement and review the change, with the final behaviour and diff reviewed and tested manually. I have also tested the upgrade and entity ID recreation behaviour on my own Home Assistant instance.