Update module properties on module scan for LCN (#135018)

This commit is contained in:
Andre Lengwenus 2025-01-09 13:44:57 +01:00 committed by GitHub
parent 9dd7021d63
commit 9dc4597f59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -423,13 +423,6 @@ async def async_create_or_update_device_in_config_entry(
device_connection.is_group, device_connection.is_group,
) )
device_configs = [*config_entry.data[CONF_DEVICES]]
data = {**config_entry.data, CONF_DEVICES: device_configs}
for device_config in data[CONF_DEVICES]:
if tuple(device_config[CONF_ADDRESS]) == address:
break # device already in config_entry
else:
# create new device_entry
device_config = { device_config = {
CONF_ADDRESS: address, CONF_ADDRESS: address,
CONF_NAME: "", CONF_NAME: "",
@ -437,11 +430,15 @@ async def async_create_or_update_device_in_config_entry(
CONF_SOFTWARE_SERIAL: -1, CONF_SOFTWARE_SERIAL: -1,
CONF_HARDWARE_TYPE: -1, CONF_HARDWARE_TYPE: -1,
} }
data[CONF_DEVICES].append(device_config)
# update device_entry device_configs = [
device
for device in config_entry.data[CONF_DEVICES]
if tuple(device[CONF_ADDRESS]) != address
]
data = {**config_entry.data, CONF_DEVICES: [*device_configs, device_config]}
await async_update_device_config(device_connection, device_config) await async_update_device_config(device_connection, device_config)
hass.config_entries.async_update_entry(config_entry, data=data) hass.config_entries.async_update_entry(config_entry, data=data)