Skip to content

Allow Home Assistant to regenerate entity IDs - #1825

Closed
sargant wants to merge 3 commits into
BottlecapDave:developfrom
sargant:allow-home-assistant-entity-ids
Closed

Allow Home Assistant to regenerate entity IDs#1825
sargant wants to merge 3 commits into
BottlecapDave:developfrom
sargant:allow-home-assistant-entity-ids

Conversation

@sargant

@sargant sargant commented Aug 17, 2026

Copy link
Copy Markdown

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 where has_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 underlying unique_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 word and even though the human-readable entity name has always been “Previous Consumption and Rates Data Last Retrieved”. Recreating that entity therefore produces previous_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.

@sargant
sargant force-pushed the allow-home-assistant-entity-ids branch from a95dd21 to be2bd34 Compare August 17, 2026 20:52
@sargant

sargant commented Aug 20, 2026

Copy link
Copy Markdown
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.

@sargant

sargant commented Aug 25, 2026

Copy link
Copy Markdown
Author

Closed - will continue work in https://github.com/sargant/HomeAssistant-OctopusEnergy/tree/adopt-ha-entity-naming in the short term

@sargant sargant closed this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant