Skip to content

Clean up stale v3 zone switches on v4 upgrade#405

Open
sebr wants to merge 1 commit intomainfrom
fix/403-migrate-v3-zone-switches
Open

Clean up stale v3 zone switches on v4 upgrade#405
sebr wants to merge 1 commit intomainfrom
fix/403-migrate-v3-zone-switches

Conversation

@sebr
Copy link
Copy Markdown
Owner

@sebr sebr commented Apr 20, 2026

Summary

  • Drop v3 zone-switch registry entries (unique_id ending in :switch) during async_setup_entry, before platforms initialise, so the v4 valve is the sole zone control in the registry.
  • Fixes the Recorder "cannot migrate history for entity_id switch.zone_1_zone to switch.pond" warning and the red/"Not provided" valve tile reported in v4 valve entities - no control and not provided #403.

Why the orphan matters

The v3→v4 switch→valve conversion changed the zone unique_id suffix from :switch to :valve. HA's registry refuses cross-domain entity_id updates, so the old switch entries stayed behind after upgrade. HA's auto-suggested entity_id for the new valve then collided with the orphaned switch, producing the Recorder warning and leaving the valve in an error state in the UI.

History on the old switch is not preserved - the platform migration already broke continuity.

Fixes #403.

Test plan

  • pytest tests/test_migration.py - 5 new tests: orphan removal, existing v4 valve preserved, non-zone switches (rain delay / smart watering / program) left alone, idempotence, config-entry scoping
  • pytest tests/ - 158 passed, 5 skipped
  • ./scripts/lint
  • Manual upgrade test on a dev instance with a pre-existing v3 registry to confirm the Recorder warning disappears and valves render normally

The v3→v4 switch→valve migration changed the zone unique_id suffix
from `:switch` to `:valve` but left the old entries behind. HA's
registry refuses cross-domain entity_id updates, so the orphaned
switches stayed put and the auto-suggested entity_id for the new valve
collided with them - surfacing as the Recorder "cannot migrate history"
warning and a red/"Not provided" valve tile.

Drop any switch entity whose unique_id still ends in `:switch` during
`async_setup_entry`, before platforms initialise, so the v4 valve is
the sole zone control in the registry.
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.

v4 valve entities - no control and not provided

1 participant