mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Guard bad entity ID in entity registry (#35271)
This commit is contained in:
parent
87d58a544b
commit
a330eba61c
@ -428,6 +428,12 @@ class EntityRegistry:
|
||||
|
||||
if data is not None:
|
||||
for entity in data["entities"]:
|
||||
# Some old installations can have some bad entities.
|
||||
# Filter them out as they cause errors down the line.
|
||||
# Can be removed in Jan 2021
|
||||
if not valid_entity_id(entity["entity_id"]):
|
||||
continue
|
||||
|
||||
entities[entity["entity_id"]] = RegistryEntry(
|
||||
entity_id=entity["entity_id"],
|
||||
config_entry_id=entity.get("config_entry_id"),
|
||||
|
@ -241,12 +241,20 @@ async def test_loading_extra_values(hass, hass_storage):
|
||||
"unique_id": "disabled-hass",
|
||||
"disabled_by": "hass",
|
||||
},
|
||||
{
|
||||
"entity_id": "test.invalid__entity",
|
||||
"platform": "super_platform",
|
||||
"unique_id": "invalid-hass",
|
||||
"disabled_by": "hass",
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
registry = await entity_registry.async_get_registry(hass)
|
||||
|
||||
assert len(registry.entities) == 4
|
||||
|
||||
entry_with_name = registry.async_get_or_create(
|
||||
"test", "super_platform", "with-name"
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user