mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +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
|
config_entry_id = None
|
||||||
|
|
||||||
device_info = entity.device_info
|
device_info = entity.device_info
|
||||||
|
device_id = None
|
||||||
|
|
||||||
if config_entry_id is not None and device_info is not None:
|
if config_entry_id is not None and device_info is not None:
|
||||||
processed_dev_info = {
|
processed_dev_info = {
|
||||||
@ -292,9 +293,8 @@ class EntityPlatform:
|
|||||||
|
|
||||||
device = device_registry.async_get_or_create(
|
device = device_registry.async_get_or_create(
|
||||||
**processed_dev_info)
|
**processed_dev_info)
|
||||||
|
if device:
|
||||||
device_id = device.id
|
device_id = device.id
|
||||||
else:
|
|
||||||
device_id = None
|
|
||||||
|
|
||||||
entry = entity_registry.async_get_or_create(
|
entry = entity_registry.async_get_or_create(
|
||||||
self.domain, self.platform_name, entity.unique_id,
|
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)
|
assert await entity_platform.async_setup_entry(config_entry)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert len(hass.states.async_entity_ids()) == 2
|
||||||
|
|
||||||
device = registry.async_get_device({('hue', '1234')}, set())
|
device = registry.async_get_device({('hue', '1234')}, set())
|
||||||
assert device is not None
|
assert device is not None
|
||||||
assert device.identifiers == {('hue', '1234')}
|
assert device.identifiers == {('hue', '1234')}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user