Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion homeassistant/components/fritzbox/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.components.ssdp import ATTR_SSDP_LOCATION, ATTR_UPNP_FRIENDLY_NAME
from homeassistant.components.ssdp import (
ATTR_SSDP_LOCATION,
ATTR_UPNP_FRIENDLY_NAME,
ATTR_UPNP_UDN,
)
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME

# pylint:disable=unused-import
Expand Down Expand Up @@ -110,12 +114,21 @@ async def async_step_ssdp(self, user_input):
host = urlparse(user_input[ATTR_SSDP_LOCATION]).hostname
self.context[CONF_HOST] = host

uuid = user_input.get(ATTR_UPNP_UDN)
if uuid:
if uuid.startswith("uuid:"):
uuid = uuid[5:]
await self.async_set_unique_id(uuid)
Comment thread
balloob marked this conversation as resolved.
self._abort_if_unique_id_configured({CONF_HOST: host})

for progress in self._async_in_progress():
if progress.get("context", {}).get(CONF_HOST) == host:
return self.async_abort(reason="already_in_progress")

for entry in self.hass.config_entries.async_entries(DOMAIN):
Comment thread
escoand marked this conversation as resolved.
if entry.data[CONF_HOST] == host:
if uuid and not entry.unique_id:
self.hass.config_entries.async_update_entry(entry, unique_id=uuid)
return self.async_abort(reason="already_configured")

self._host = host
Expand Down