Update the ip/port in the homekit_controller config entry when it changes (#52554)
This commit is contained in:
parent
7d87efc996
commit
3191fef8d6
2 changed files with 65 additions and 6 deletions
|
@ -236,9 +236,20 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
)
|
||||
config_num = None
|
||||
|
||||
# Set unique-id and error out if it's already configured
|
||||
existing_entry = await self.async_set_unique_id(normalize_hkid(hkid))
|
||||
updated_ip_port = {
|
||||
"AccessoryIP": discovery_info["host"],
|
||||
"AccessoryPort": discovery_info["port"],
|
||||
}
|
||||
|
||||
# If the device is already paired and known to us we should monitor c#
|
||||
# (config_num) for changes. If it changes, we check for new entities
|
||||
if paired and hkid in self.hass.data.get(KNOWN_DEVICES, {}):
|
||||
if existing_entry:
|
||||
self.hass.config_entries.async_update_entry(
|
||||
existing_entry, data={**existing_entry.data, **updated_ip_port}
|
||||
)
|
||||
conn = self.hass.data[KNOWN_DEVICES][hkid]
|
||||
# When we rediscover the device, let aiohomekit know
|
||||
# that the device is available and we should not wait
|
||||
|
@ -262,8 +273,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
await self.hass.config_entries.async_remove(existing.entry_id)
|
||||
|
||||
# Set unique-id and error out if it's already configured
|
||||
await self.async_set_unique_id(normalize_hkid(hkid))
|
||||
self._abort_if_unique_id_configured()
|
||||
self._abort_if_unique_id_configured(updates=updated_ip_port)
|
||||
|
||||
self.context["hkid"] = hkid
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue