Guard for bad device info (#17238)

This commit is contained in:
Paulus Schoutsen 2018-10-08 12:53:51 +02:00 committed by GitHub
parent af2402ea59
commit d5f5273c31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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)
if device:
device_id = device.id
else:
device_id = None
entry = entity_registry.async_get_or_create(
self.domain, self.platform_name, entity.unique_id,

View File

@ -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')}