mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Use ConfigFlow.has_matching_flow to deduplicate hunterdouglas flows (#126895)
This commit is contained in:
parent
a3ec4db9cc
commit
85ebe5e01a
@ -3,7 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any, Self
|
||||||
|
|
||||||
from aiopvapi.helpers.aiorequest import AioRequest
|
from aiopvapi.helpers.aiorequest import AioRequest
|
||||||
from aiopvapi.hub import Hub
|
from aiopvapi.hub import Hub
|
||||||
@ -152,9 +152,7 @@ class PowerviewConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
# If we already have the host configured do
|
# If we already have the host configured do
|
||||||
# not open connections to it if we can avoid it.
|
# not open connections to it if we can avoid it.
|
||||||
assert self.discovered_ip and self.discovered_name is not None
|
assert self.discovered_ip and self.discovered_name is not None
|
||||||
self.context[CONF_HOST] = self.discovered_ip
|
if self.hass.config_entries.flow.async_has_matching_flow(self):
|
||||||
for progress in self._async_in_progress():
|
|
||||||
if progress.get("context", {}).get(CONF_HOST) == self.discovered_ip:
|
|
||||||
return self.async_abort(reason="already_in_progress")
|
return self.async_abort(reason="already_in_progress")
|
||||||
|
|
||||||
self._async_abort_entries_match({CONF_HOST: self.discovered_ip})
|
self._async_abort_entries_match({CONF_HOST: self.discovered_ip})
|
||||||
@ -177,6 +175,10 @@ class PowerviewConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
}
|
}
|
||||||
return await self.async_step_link()
|
return await self.async_step_link()
|
||||||
|
|
||||||
|
def is_matching(self, other_flow: Self) -> bool:
|
||||||
|
"""Return True if other_flow is matching this flow."""
|
||||||
|
return other_flow.discovered_ip == self.discovered_ip
|
||||||
|
|
||||||
async def async_step_link(
|
async def async_step_link(
|
||||||
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