Prevent accidental device reg override (#17136)
This commit is contained in:
1 parent
59d78b060f
commit
4b7f85518f
2 files changed
+59
-10
No files matched your search
@@ -275,17 +275,24 @@ class EntityPlatform:
|
||||
device_info = entity.device_info
|
||||
|
||||
if config_entry_id is not None and device_info is not None:
|
||||
processed_dev_info = {
|
||||
'config_entry_id': config_entry_id
|
||||
}
|
||||
for key in (
|
||||
'connections',
|
||||
'identifiers',
|
||||
'manufacturer',
|
||||
'model',
|
||||
'name',
|
||||
'sw_version',
|
||||
'via_hub',
|
||||
):
|
||||
if key in device_info:
|
||||
processed_dev_info[key] = device_info[key]
|
||||
|
||||
device = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry_id,
|
||||
connections=device_info.get('connections') or set(),
|
||||
identifiers=device_info.get('identifiers') or set(),
|
||||
manufacturer=device_info.get('manufacturer'),
|
||||
model=device_info.get('model'),
|
||||
name=device_info.get('name'),
|
||||
sw_version=device_info.get('sw_version'),
|
||||
via_hub=device_info.get('via_hub'))
|
||||
if device:
|
||||
device_id = device.id
|
||||
**processed_dev_info)
|
||||
device_id = device.id
|
||||
else:
|
||||
device_id = None
|
||||
|
||||
|
||||
Reference in new issue
Block a user