mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Fix lcn in place update of config entry data (#58729)
* Fix in place update of config entry data * Deep copy of device configs * Fix review comments
This commit is contained in:
parent
c469358e5f
commit
f4c823f338
@ -2,6 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from copy import deepcopy
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import re
|
import re
|
||||||
from typing import Tuple, Type, Union, cast
|
from typing import Tuple, Type, Union, cast
|
||||||
@ -336,8 +337,9 @@ async def async_update_config_entry(
|
|||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: ConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Fill missing values in config_entry with infos from LCN bus."""
|
"""Fill missing values in config_entry with infos from LCN bus."""
|
||||||
|
device_configs = deepcopy(config_entry.data[CONF_DEVICES])
|
||||||
coros = []
|
coros = []
|
||||||
for device_config in config_entry.data[CONF_DEVICES]:
|
for device_config in device_configs:
|
||||||
device_connection = get_device_connection(
|
device_connection = get_device_connection(
|
||||||
hass, device_config[CONF_ADDRESS], config_entry
|
hass, device_config[CONF_ADDRESS], config_entry
|
||||||
)
|
)
|
||||||
@ -345,8 +347,10 @@ async def async_update_config_entry(
|
|||||||
|
|
||||||
await asyncio.gather(*coros)
|
await asyncio.gather(*coros)
|
||||||
|
|
||||||
|
new_data = {**config_entry.data, CONF_DEVICES: device_configs}
|
||||||
|
|
||||||
# schedule config_entry for save
|
# schedule config_entry for save
|
||||||
hass.config_entries.async_update_entry(config_entry)
|
hass.config_entries.async_update_entry(config_entry, data=new_data)
|
||||||
|
|
||||||
|
|
||||||
def has_unique_host_names(hosts: list[ConfigType]) -> list[ConfigType]:
|
def has_unique_host_names(hosts: list[ConfigType]) -> list[ConfigType]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user