diff --git a/homeassistant/components/webostv/config_flow.py b/homeassistant/components/webostv/config_flow.py index 45395bd282a15b929404478a5a6adea4e58fa54d..9a5eda7bbf7481bb105a58e4b5cc6c1b0385402e 100644 --- a/homeassistant/components/webostv/config_flow.py +++ b/homeassistant/components/webostv/config_flow.py @@ -3,7 +3,6 @@ from __future__ import annotations from collections.abc import Mapping -import logging from typing import Any, Self from urllib.parse import urlparse @@ -19,7 +18,6 @@ from homeassistant.config_entries import ( ) from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST, CONF_NAME from homeassistant.core import callback -from homeassistant.data_entry_flow import AbortFlow from homeassistant.helpers import config_validation as cv from . import async_control_connect, update_client_key @@ -34,8 +32,6 @@ DATA_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -_LOGGER = logging.getLogger(__name__) - class FlowHandler(ConfigFlow, domain=DOMAIN): """WebosTV configuration flow.""" @@ -68,28 +64,11 @@ class FlowHandler(ConfigFlow, domain=DOMAIN): step_id="user", data_schema=DATA_SCHEMA, errors=errors ) - @callback - def _async_check_configured_entry(self) -> None: - """Check if entry is configured, update unique_id if needed.""" - for entry in self._async_current_entries(include_ignore=False): - if entry.data[CONF_HOST] != self._host: - continue - - if self._uuid and not entry.unique_id: - _LOGGER.debug( - "Updating unique_id for host %s, unique_id: %s", - self._host, - self._uuid, - ) - self.hass.config_entries.async_update_entry(entry, unique_id=self._uuid) - - raise AbortFlow("already_configured") - async def async_step_pairing( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Display pairing form.""" - self._async_check_configured_entry() + self._async_abort_entries_match({CONF_HOST: self._host}) self.context["title_placeholders"] = {"name": self._name} errors = {} diff --git a/homeassistant/components/webostv/quality_scale.yaml b/homeassistant/components/webostv/quality_scale.yaml index 0bd5990da4f727137c4d39d19d0db02de9d412b3..b6a6a5e99a495a7720b5dd07e21691b6ccf4c702 100644 --- a/homeassistant/components/webostv/quality_scale.yaml +++ b/homeassistant/components/webostv/quality_scale.yaml @@ -11,7 +11,7 @@ rules: config-flow-test-coverage: todo config-flow: status: todo - comment: remove duplicated config flow start in tests, make sure tests ends with CREATE_ENTRY or ABORT, remove legacy uuid migration, remove name parameter, use hass.config_entries.async_setup instead of async_setup_component, snapshot in diagnostics (and other tests when possible), test_client_disconnected validate no error in log, make reauth flow more graceful + comment: remove duplicated config flow start in tests, make sure tests ends with CREATE_ENTRY or ABORT, remove name parameter, use hass.config_entries.async_setup instead of async_setup_component, snapshot in diagnostics (and other tests when possible), test_client_disconnected validate no error in log, make reauth flow more graceful dependency-transparency: done docs-actions: status: todo diff --git a/tests/components/webostv/test_config_flow.py b/tests/components/webostv/test_config_flow.py index 9b2983aab47a5052ebdccb26a540013e61bbf3fb..cc335a4fb41a0f6c487c7288a4e0e50d2b8150fd 100644 --- a/tests/components/webostv/test_config_flow.py +++ b/tests/components/webostv/test_config_flow.py @@ -218,22 +218,6 @@ async def test_ssdp_in_progress(hass: HomeAssistant, client) -> None: assert result2["reason"] == "already_in_progress" -async def test_ssdp_update_uuid(hass: HomeAssistant, client) -> None: - """Test that ssdp updates existing host entry uuid.""" - entry = await setup_webostv(hass, None) - assert client - assert entry.unique_id is None - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVERY_INFO - ) - await hass.async_block_till_done() - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "already_configured" - assert entry.unique_id == MOCK_DISCOVERY_INFO.upnp[ssdp.ATTR_UPNP_UDN][5:] - - async def test_ssdp_not_update_uuid(hass: HomeAssistant, client) -> None: """Test that ssdp not updates different host.""" entry = await setup_webostv(hass, None)