Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions homeassistant/helpers/entity_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ async def _async_add_entity(self, entity, update_before_add,
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 = {
Expand All @@ -292,9 +293,8 @@ async def _async_add_entity(self, entity, update_before_add,

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,
Expand Down
2 changes: 2 additions & 0 deletions tests/helpers/test_entity_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
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')}
Expand Down