mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Guard for bad device info (#17238)
This commit is contained in:
parent
af2402ea59
commit
d5f5273c31
@ -273,6 +273,7 @@ class EntityPlatform:
|
||||
config_entry_id = None
|
||||
|
||||
device_info = entity.device_info
|
||||
device_id = None
|
||||
|
||||
if config_entry_id is not None and device_info is not None:
|
||||
processed_dev_info = {
|
||||
@ -292,9 +293,8 @@ class EntityPlatform:
|
||||
|
||||
device = device_registry.async_get_or_create(
|
||||
**processed_dev_info)
|
||||
device_id = device.id
|
||||
else:
|
||||
device_id = None
|
||||
if device:
|
||||
device_id = device.id
|
||||
|
||||
entry = entity_registry.async_get_or_create(
|
||||
self.domain, self.platform_name, entity.unique_id,
|
||||
|
@ -719,6 +719,8 @@ async def test_device_info_called(hass):
|
||||
assert await entity_platform.async_setup_entry(config_entry)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_entity_ids()) == 2
|
||||
|
||||
device = registry.async_get_device({('hue', '1234')}, set())
|
||||
assert device is not None
|
||||
assert device.identifiers == {('hue', '1234')}
|
||||
|
Loading…
x
Reference in New Issue
Block a user