diff --git a/homeassistant/components/tag/__init__.py b/homeassistant/components/tag/__init__.py index ca0d53be6d0..45266652a47 100644 --- a/homeassistant/components/tag/__init__.py +++ b/homeassistant/components/tag/__init__.py @@ -34,7 +34,7 @@ LAST_SCANNED = "last_scanned" LAST_SCANNED_BY_DEVICE_ID = "last_scanned_by_device_id" STORAGE_KEY = DOMAIN STORAGE_VERSION = 1 -STORAGE_VERSION_MINOR = 2 +STORAGE_VERSION_MINOR = 3 TAG_DATA: HassKey[TagStorageCollection] = HassKey(DOMAIN) SIGNAL_TAG_CHANGED = "signal_tag_changed" @@ -109,6 +109,12 @@ class TagStore(Store[collection.SerializedStorageCollection]): # Copy name in tag store to the entity registry _create_entry(entity_registry, tag[CONF_ID], tag.get(CONF_NAME)) tag["migrated"] = True + if old_major_version == 1 and old_minor_version < 3: + # Version 1.3 removes tag_id from the store + for tag in data["items"]: + if TAG_ID not in tag: + continue + del tag[TAG_ID] if old_major_version > 1: raise NotImplementedError diff --git a/tests/components/tag/snapshots/test_init.ambr b/tests/components/tag/snapshots/test_init.ambr index bfa80d8462e..29a9a2665b8 100644 --- a/tests/components/tag/snapshots/test_init.ambr +++ b/tests/components/tag/snapshots/test_init.ambr @@ -7,7 +7,6 @@ 'id': 'test tag id', 'migrated': True, 'name': 'test tag name', - 'tag_id': 'test tag id', }), dict({ 'device_id': 'some_scanner', @@ -20,7 +19,7 @@ ]), }), 'key': 'tag', - 'minor_version': 2, + 'minor_version': 3, 'version': 1, }) # --- diff --git a/tests/components/tag/test_init.py b/tests/components/tag/test_init.py index 295f286159e..bc9602fd1cb 100644 --- a/tests/components/tag/test_init.py +++ b/tests/components/tag/test_init.py @@ -97,9 +97,7 @@ async def test_migration( await client.send_json_auto_id({"type": f"{DOMAIN}/list"}) resp = await client.receive_json() assert resp["success"] - assert resp["result"] == [ - {"id": TEST_TAG_ID, "name": "test tag name", "tag_id": TEST_TAG_ID} - ] + assert resp["result"] == [{"id": TEST_TAG_ID, "name": "test tag name"}] # Scan a new tag await async_scan_tag(hass, "new tag", "some_scanner")