Use ConfigFlow.has_matching_flow to deduplicate webostv flows (#126898)

pull/126967/head
Erik Montnemery 2024-09-27 23:11:15 +02:00 committed by GitHub
parent 1044345587
commit 6c1167df4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 5 deletions

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Mapping
import logging
from typing import Any
from typing import Any, Self
from urllib.parse import urlparse
from aiowebostv import WebOsTvPairError
@ -92,7 +92,6 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
"""Display pairing form."""
self._async_check_configured_entry()
self.context[CONF_HOST] = self._host
self.context["title_placeholders"] = {"name": self._name}
errors = {}
@ -130,13 +129,16 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(uuid)
self._abort_if_unique_id_configured({CONF_HOST: self._host})
for progress in self._async_in_progress():
if progress.get("context", {}).get(CONF_HOST) == self._host:
return self.async_abort(reason="already_in_progress")
if self.hass.config_entries.flow.async_has_matching_flow(self):
return self.async_abort(reason="already_in_progress")
self._uuid = uuid
return await self.async_step_pairing()
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_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult: