mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use ConfigFlow.has_matching_flow to deduplicate fritz flows (#126890)
This commit is contained in:
parent
b34f3ad5c5
commit
fcbb9dd8d8
@ -6,7 +6,7 @@ from collections.abc import Mapping
|
|||||||
import ipaddress
|
import ipaddress
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
from typing import Any
|
from typing import Any, Self
|
||||||
from urllib.parse import ParseResult, urlparse
|
from urllib.parse import ParseResult, urlparse
|
||||||
|
|
||||||
from fritzconnection import FritzConnection
|
from fritzconnection import FritzConnection
|
||||||
@ -155,7 +155,6 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME)
|
discovery_info.upnp.get(ssdp.ATTR_UPNP_FRIENDLY_NAME)
|
||||||
or discovery_info.upnp[ssdp.ATTR_UPNP_MODEL_NAME]
|
or discovery_info.upnp[ssdp.ATTR_UPNP_MODEL_NAME]
|
||||||
)
|
)
|
||||||
self.context[CONF_HOST] = self._host
|
|
||||||
|
|
||||||
if not self._host or ipaddress.ip_address(self._host).is_link_local:
|
if not self._host or ipaddress.ip_address(self._host).is_link_local:
|
||||||
return self.async_abort(reason="ignore_ip6_link_local")
|
return self.async_abort(reason="ignore_ip6_link_local")
|
||||||
@ -166,9 +165,8 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
await self.async_set_unique_id(uuid)
|
await self.async_set_unique_id(uuid)
|
||||||
self._abort_if_unique_id_configured({CONF_HOST: self._host})
|
self._abort_if_unique_id_configured({CONF_HOST: self._host})
|
||||||
|
|
||||||
for progress in self._async_in_progress():
|
if self.hass.config_entries.flow.async_has_matching_flow(self):
|
||||||
if progress.get("context", {}).get(CONF_HOST) == self._host:
|
return self.async_abort(reason="already_in_progress")
|
||||||
return self.async_abort(reason="already_in_progress")
|
|
||||||
|
|
||||||
if entry := await self.async_check_configured_entry():
|
if entry := await self.async_check_configured_entry():
|
||||||
if uuid and not entry.unique_id:
|
if uuid and not entry.unique_id:
|
||||||
@ -184,6 +182,10 @@ class FritzBoxToolsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
return await self.async_step_confirm()
|
return await self.async_step_confirm()
|
||||||
|
|
||||||
|
def is_matching(self, other_flow: Self) -> bool:
|
||||||
|
"""Return True if other_flow is matching this flow."""
|
||||||
|
return other_flow._host == self._host # noqa: SLF001
|
||||||
|
|
||||||
async def async_step_confirm(
|
async def async_step_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user