Handle device IP change in upnp (#46859)

pull/46933/head
Steven Looman 2021-02-24 04:00:47 +01:00 committed by GitHub
parent 19f5b467b7
commit 3e26e2adad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -123,7 +123,10 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry)
) )
# Ensure entry has a hostname, for older entries. # Ensure entry has a hostname, for older entries.
if CONFIG_ENTRY_HOSTNAME not in config_entry.data: if (
CONFIG_ENTRY_HOSTNAME not in config_entry.data
or config_entry.data[CONFIG_ENTRY_HOSTNAME] != device.hostname
):
hass.config_entries.async_update_entry( hass.config_entries.async_update_entry(
entry=config_entry, entry=config_entry,
data={CONFIG_ENTRY_HOSTNAME: device.hostname, **config_entry.data}, data={CONFIG_ENTRY_HOSTNAME: device.hostname, **config_entry.data},

View File

@ -179,7 +179,9 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
discovery = await Device.async_supplement_discovery(self.hass, discovery) discovery = await Device.async_supplement_discovery(self.hass, discovery)
unique_id = discovery[DISCOVERY_UNIQUE_ID] unique_id = discovery[DISCOVERY_UNIQUE_ID]
await self.async_set_unique_id(unique_id) await self.async_set_unique_id(unique_id)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured(
updates={CONFIG_ENTRY_HOSTNAME: discovery[DISCOVERY_HOSTNAME]}
)
# Handle devices changing their UDN, only allow a single # Handle devices changing their UDN, only allow a single
existing_entries = self.hass.config_entries.async_entries(DOMAIN) existing_entries = self.hass.config_entries.async_entries(DOMAIN)