mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove tag_id from tag store (#118713)
This commit is contained in:
parent
85982d2b87
commit
f3d1157bc4
@ -34,7 +34,7 @@ LAST_SCANNED = "last_scanned"
|
|||||||
LAST_SCANNED_BY_DEVICE_ID = "last_scanned_by_device_id"
|
LAST_SCANNED_BY_DEVICE_ID = "last_scanned_by_device_id"
|
||||||
STORAGE_KEY = DOMAIN
|
STORAGE_KEY = DOMAIN
|
||||||
STORAGE_VERSION = 1
|
STORAGE_VERSION = 1
|
||||||
STORAGE_VERSION_MINOR = 2
|
STORAGE_VERSION_MINOR = 3
|
||||||
|
|
||||||
TAG_DATA: HassKey[TagStorageCollection] = HassKey(DOMAIN)
|
TAG_DATA: HassKey[TagStorageCollection] = HassKey(DOMAIN)
|
||||||
SIGNAL_TAG_CHANGED = "signal_tag_changed"
|
SIGNAL_TAG_CHANGED = "signal_tag_changed"
|
||||||
@ -109,6 +109,12 @@ class TagStore(Store[collection.SerializedStorageCollection]):
|
|||||||
# Copy name in tag store to the entity registry
|
# Copy name in tag store to the entity registry
|
||||||
_create_entry(entity_registry, tag[CONF_ID], tag.get(CONF_NAME))
|
_create_entry(entity_registry, tag[CONF_ID], tag.get(CONF_NAME))
|
||||||
tag["migrated"] = True
|
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:
|
if old_major_version > 1:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
'id': 'test tag id',
|
'id': 'test tag id',
|
||||||
'migrated': True,
|
'migrated': True,
|
||||||
'name': 'test tag name',
|
'name': 'test tag name',
|
||||||
'tag_id': 'test tag id',
|
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
'device_id': 'some_scanner',
|
'device_id': 'some_scanner',
|
||||||
@ -20,7 +19,7 @@
|
|||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
'key': 'tag',
|
'key': 'tag',
|
||||||
'minor_version': 2,
|
'minor_version': 3,
|
||||||
'version': 1,
|
'version': 1,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
@ -97,9 +97,7 @@ async def test_migration(
|
|||||||
await client.send_json_auto_id({"type": f"{DOMAIN}/list"})
|
await client.send_json_auto_id({"type": f"{DOMAIN}/list"})
|
||||||
resp = await client.receive_json()
|
resp = await client.receive_json()
|
||||||
assert resp["success"]
|
assert resp["success"]
|
||||||
assert resp["result"] == [
|
assert resp["result"] == [{"id": TEST_TAG_ID, "name": "test tag name"}]
|
||||||
{"id": TEST_TAG_ID, "name": "test tag name", "tag_id": TEST_TAG_ID}
|
|
||||||
]
|
|
||||||
|
|
||||||
# Scan a new tag
|
# Scan a new tag
|
||||||
await async_scan_tag(hass, "new tag", "some_scanner")
|
await async_scan_tag(hass, "new tag", "some_scanner")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user