Skip to content

Add a choice to reuse retiring entity IDs and retained history - #6

Merged
FortranFour merged 1 commit into
mainfrom
feature/entity-id-reuse
Oct 25, 2026
Merged

FortranFour merged 1 commit into
mainfrom
feature/entity-id-reuse

Conversation

@FortranFour

Copy link
Copy Markdown
Owner

Add an initial strategy selector: update references to the replacement's IDs (existing default workflow), or assign the retiring entity IDs to the replacement entities so retained old history stays at those IDs.

ID reuse behavior

  • Works with reviewed whole-device mappings or a single entity. The replacement retains its own device identity, unique IDs, pairing and registry UUIDs.
  • Requires disabled/unloaded entities, verified role/unit compatibility, permanent retirement/disconnection of old hardware and explicit confirmation of a full Home Assistant backup including recorder data.
  • Removes only the mapped old entity registry entries without renaming them, then uses HA's native registry rename API on the replacement. Renaming old entries would move their history away, so that is deliberately avoided.
  • Uses recorder barriers and read-only metadata snapshots to verify preserved old raw-history/statistics identities. No SQL writes, direct storage edits or historical measurement copies.
  • Existing replacement history remains separate when an old series exists; no merge is claimed. Where the old series is absent, native HA rename may carry the replacement's series to the reused ID.
  • Reports replacement-ID references and old device-ID/registry-UUID bindings for manual repair. This mode does not edit configuration references, transfer device identity, or copy areas/labels. Unmapped entities are untouched.
  • Cumulative counters, including Energy Dashboard kWh totals, remain blocked; name reuse alone cannot guarantee their numerical continuity.
  • Session-owned expiring previews, revalidation before writes, durable audits, no blind retry after partial/interrupted operations, and backend/UI exclusion from configuration Restore. Unresolved operations block affected history actions across restarts.

Validation

116 standalone tests and 11 real HA 2026.3.0 SQLite recorder tests pass. Recorder tests cover unchanged raw/statistic rows, existing history on both sides, removed sources, multi-entity batches with untouched unmapped entities, continued new readings under old metadata IDs, and counter/readiness rejection. Failure tests cover identity/history drift, consent/session/expiry, partial failures, cancellation, audit-write failure and persistent blocking. Frontend unit tests and Chromium device/entity workflows at 1360px/390px pass, including separate consent, readiness, audit exclusion and overflow checks. Package/syntax/whitespace checks pass.

Prepares v1.3.0 as a testing prerelease through the existing checked publication workflow. Stable remains v1.1.3. Related to #1; this does not implement statistics merging or Energy Dashboard counter migration.

@FortranFour
FortranFour merged commit 92d5e1b into main Oct 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant