From a4ea9b3cd39609a87f22173fa14f4fc8cb38dbbf Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 May 2021 05:47:06 -0500 Subject: [PATCH] Update usage of async_entries to use _async_current_entries (#50187) --- homeassistant/components/awair/config_flow.py | 2 +- homeassistant/components/blebox/config_flow.py | 2 +- homeassistant/components/dynalite/config_flow.py | 2 +- homeassistant/components/fritzbox/config_flow.py | 2 +- homeassistant/components/glances/config_flow.py | 11 +---------- homeassistant/components/hlk_sw16/config_flow.py | 14 ++++---------- homeassistant/components/hlk_sw16/errors.py | 4 ---- homeassistant/components/iaqualink/config_flow.py | 2 +- homeassistant/components/life360/config_flow.py | 2 +- homeassistant/components/litejet/config_flow.py | 2 +- .../components/logi_circle/config_flow.py | 2 +- homeassistant/components/mikrotik/config_flow.py | 2 +- homeassistant/components/mysensors/config_flow.py | 6 +++--- homeassistant/components/nest/config_flow.py | 8 ++++---- homeassistant/components/omnilogic/config_flow.py | 2 +- .../components/opentherm_gw/config_flow.py | 2 +- homeassistant/components/point/config_flow.py | 8 ++++---- homeassistant/components/ps4/config_flow.py | 2 +- homeassistant/components/soma/config_flow.py | 2 +- homeassistant/components/somfy/config_flow.py | 2 +- .../components/tellduslive/config_flow.py | 4 ++-- .../components/transmission/config_flow.py | 2 +- homeassistant/components/upnp/config_flow.py | 2 +- homeassistant/components/vesync/__init__.py | 3 +-- homeassistant/components/vesync/config_flow.py | 8 +------- homeassistant/components/vizio/config_flow.py | 2 +- homeassistant/components/withings/config_flow.py | 2 +- tests/components/hlk_sw16/test_config_flow.py | 5 ++--- 28 files changed, 40 insertions(+), 67 deletions(-) diff --git a/homeassistant/components/awair/config_flow.py b/homeassistant/components/awair/config_flow.py index 3854909bc86..2214fc30519 100644 --- a/homeassistant/components/awair/config_flow.py +++ b/homeassistant/components/awair/config_flow.py @@ -19,7 +19,7 @@ class AwairFlowHandler(ConfigFlow, domain=DOMAIN): async def async_step_import(self, conf: dict): """Import a configuration from config.yaml.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="already_setup") user, error = await self._check_connection(conf[CONF_ACCESS_TOKEN]) diff --git a/homeassistant/components/blebox/config_flow.py b/homeassistant/components/blebox/config_flow.py index d310232f776..17dffe154d1 100644 --- a/homeassistant/components/blebox/config_flow.py +++ b/homeassistant/components/blebox/config_flow.py @@ -91,7 +91,7 @@ class BleBoxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): addr = host_port(user_input) - for entry in hass.config_entries.async_entries(DOMAIN): + for entry in self._async_current_entries(): if addr == host_port(entry.data): host, port = addr return self.async_abort( diff --git a/homeassistant/components/dynalite/config_flow.py b/homeassistant/components/dynalite/config_flow.py index 9b2b76318f1..e1d062a6058 100644 --- a/homeassistant/components/dynalite/config_flow.py +++ b/homeassistant/components/dynalite/config_flow.py @@ -23,7 +23,7 @@ class DynaliteFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Import a new bridge as a config entry.""" LOGGER.debug("Starting async_step_import - %s", import_info) host = import_info[CONF_HOST] - for entry in self.hass.config_entries.async_entries(DOMAIN): + for entry in self._async_current_entries(): if entry.data[CONF_HOST] == host: if entry.data != import_info: self.hass.config_entries.async_update_entry(entry, data=import_info) diff --git a/homeassistant/components/fritzbox/config_flow.py b/homeassistant/components/fritzbox/config_flow.py index ecbcfa0bf68..50a9a5f0117 100644 --- a/homeassistant/components/fritzbox/config_flow.py +++ b/homeassistant/components/fritzbox/config_flow.py @@ -128,7 +128,7 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_abort(reason="already_in_progress") # update old and user-configured config entries - for entry in self.hass.config_entries.async_entries(DOMAIN): + for entry in self._async_current_entries(): if entry.data[CONF_HOST] == host: if uuid and not entry.unique_id: self.hass.config_entries.async_update_entry(entry, unique_id=uuid) diff --git a/homeassistant/components/glances/config_flow.py b/homeassistant/components/glances/config_flow.py index 981c3727b8e..f00f3ca42f8 100644 --- a/homeassistant/components/glances/config_flow.py +++ b/homeassistant/components/glances/config_flow.py @@ -43,10 +43,6 @@ DATA_SCHEMA = vol.Schema( async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect.""" - for entry in hass.config_entries.async_entries(DOMAIN): - if entry.data[CONF_HOST] == data[CONF_HOST]: - raise AlreadyConfigured - if data[CONF_VERSION] not in SUPPORTED_VERSIONS: raise WrongVersion try: @@ -71,13 +67,12 @@ class GlancesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" errors = {} if user_input is not None: + self._async_abort_entries_match({CONF_HOST: user_input[CONF_HOST]}) try: await validate_input(self.hass, user_input) return self.async_create_entry( title=user_input[CONF_NAME], data=user_input ) - except AlreadyConfigured: - return self.async_abort(reason="already_configured") except CannotConnect: errors["base"] = "cannot_connect" except WrongVersion: @@ -121,9 +116,5 @@ class CannotConnect(exceptions.HomeAssistantError): """Error to indicate we cannot connect.""" -class AlreadyConfigured(exceptions.HomeAssistantError): - """Error to indicate host is already configured.""" - - class WrongVersion(exceptions.HomeAssistantError): """Error to indicate the selected version is wrong.""" diff --git a/homeassistant/components/hlk_sw16/config_flow.py b/homeassistant/components/hlk_sw16/config_flow.py index 6f4e6ce708c..ca65647a448 100644 --- a/homeassistant/components/hlk_sw16/config_flow.py +++ b/homeassistant/components/hlk_sw16/config_flow.py @@ -15,7 +15,7 @@ from .const import ( DEFAULT_RECONNECT_INTERVAL, DOMAIN, ) -from .errors import AlreadyConfigured, CannotConnect +from .errors import CannotConnect DATA_SCHEMA = vol.Schema( { @@ -40,13 +40,6 @@ async def connect_client(hass, user_input): async def validate_input(hass: HomeAssistant, user_input): """Validate the user input allows us to connect.""" - for entry in hass.config_entries.async_entries(DOMAIN): - if ( - entry.data[CONF_HOST] == user_input[CONF_HOST] - and entry.data[CONF_PORT] == user_input[CONF_PORT] - ): - raise AlreadyConfigured - try: client = await connect_client(hass, user_input) except asyncio.TimeoutError as err: @@ -81,12 +74,13 @@ class SW16FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" errors = {} if user_input is not None: + self._async_abort_entries_match( + {CONF_HOST: user_input[CONF_HOST], CONF_PORT: user_input[CONF_PORT]} + ) try: await validate_input(self.hass, user_input) address = f"{user_input[CONF_HOST]}:{user_input[CONF_PORT]}" return self.async_create_entry(title=address, data=user_input) - except AlreadyConfigured: - errors["base"] = "already_configured" except CannotConnect: errors["base"] = "cannot_connect" diff --git a/homeassistant/components/hlk_sw16/errors.py b/homeassistant/components/hlk_sw16/errors.py index 5b29587deba..87453737531 100644 --- a/homeassistant/components/hlk_sw16/errors.py +++ b/homeassistant/components/hlk_sw16/errors.py @@ -6,9 +6,5 @@ class SW16Exception(HomeAssistantError): """Base class for HLK-SW16 exceptions.""" -class AlreadyConfigured(SW16Exception): - """HLK-SW16 is already configured.""" - - class CannotConnect(SW16Exception): """Unable to connect to the HLK-SW16.""" diff --git a/homeassistant/components/iaqualink/config_flow.py b/homeassistant/components/iaqualink/config_flow.py index 235b45ca5af..96c82cd2c76 100644 --- a/homeassistant/components/iaqualink/config_flow.py +++ b/homeassistant/components/iaqualink/config_flow.py @@ -19,7 +19,7 @@ class AqualinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user(self, user_input: ConfigType | None = None): """Handle a flow start.""" # Supporting a single account. - entries = self.hass.config_entries.async_entries(DOMAIN) + entries = self._async_current_entries() if entries: return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/life360/config_flow.py b/homeassistant/components/life360/config_flow.py index 78ec938586d..0a200e72097 100644 --- a/homeassistant/components/life360/config_flow.py +++ b/homeassistant/components/life360/config_flow.py @@ -30,7 +30,7 @@ class Life360ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @property def configured_usernames(self): """Return tuple of configured usernames.""" - entries = self.hass.config_entries.async_entries(DOMAIN) + entries = self._async_current_entries() if entries: return (entry.data[CONF_USERNAME] for entry in entries) return () diff --git a/homeassistant/components/litejet/config_flow.py b/homeassistant/components/litejet/config_flow.py index a4de9d883e4..2e63c150e41 100644 --- a/homeassistant/components/litejet/config_flow.py +++ b/homeassistant/components/litejet/config_flow.py @@ -24,7 +24,7 @@ class LiteJetConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Create a LiteJet config entry based upon user input.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") errors = {} diff --git a/homeassistant/components/logi_circle/config_flow.py b/homeassistant/components/logi_circle/config_flow.py index ff0fd83ff5b..d61de1ea017 100644 --- a/homeassistant/components/logi_circle/config_flow.py +++ b/homeassistant/components/logi_circle/config_flow.py @@ -95,7 +95,7 @@ class LogiCircleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_auth(self, user_input=None): """Create an entry for auth.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="external_setup") external_error = self.hass.data[DATA_FLOW_IMPL][DOMAIN][EXTERNAL_ERRORS] diff --git a/homeassistant/components/mikrotik/config_flow.py b/homeassistant/components/mikrotik/config_flow.py index 7208c96d18f..922df221d5a 100644 --- a/homeassistant/components/mikrotik/config_flow.py +++ b/homeassistant/components/mikrotik/config_flow.py @@ -40,7 +40,7 @@ class MikrotikFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Handle a flow initialized by the user.""" errors = {} if user_input is not None: - for entry in self.hass.config_entries.async_entries(DOMAIN): + for entry in self._async_current_entries(): if entry.data[CONF_HOST] == user_input[CONF_HOST]: return self.async_abort(reason="already_configured") if entry.data[CONF_NAME] == user_input[CONF_NAME]: diff --git a/homeassistant/components/mysensors/config_flow.py b/homeassistant/components/mysensors/config_flow.py index 847408abcc5..6676e11febf 100644 --- a/homeassistant/components/mysensors/config_flow.py +++ b/homeassistant/components/mysensors/config_flow.py @@ -218,7 +218,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return self.async_show_form(step_id="gw_tcp", data_schema=schema, errors=errors) def _check_topic_exists(self, topic: str) -> bool: - for other_config in self.hass.config_entries.async_entries(DOMAIN): + for other_config in self._async_current_entries(): if topic == other_config.data.get( CONF_TOPIC_IN_PREFIX ) or topic == other_config.data.get(CONF_TOPIC_OUT_PREFIX): @@ -329,7 +329,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ] = self._normalize_persistence_file( user_input[CONF_PERSISTENCE_FILE] ) - for other_entry in self.hass.config_entries.async_entries(DOMAIN): + for other_entry in self._async_current_entries(): if CONF_PERSISTENCE_FILE not in other_entry.data: continue if real_persistence_path == self._normalize_persistence_file( @@ -338,7 +338,7 @@ class MySensorsConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): errors[CONF_PERSISTENCE_FILE] = "duplicate_persistence_file" break - for other_entry in self.hass.config_entries.async_entries(DOMAIN): + for other_entry in self._async_current_entries(): if _is_same_device(gw_type, user_input, other_entry): errors["base"] = "already_configured" break diff --git a/homeassistant/components/nest/config_flow.py b/homeassistant/components/nest/config_flow.py index cd705d816c2..c6ebe543c99 100644 --- a/homeassistant/components/nest/config_flow.py +++ b/homeassistant/components/nest/config_flow.py @@ -112,7 +112,7 @@ class NestFlowHandler( # Update existing config entry when in the reauth flow. This # integration only supports one config entry so remove any prior entries # added before the "single_instance_allowed" check was added - existing_entries = self.hass.config_entries.async_entries(DOMAIN) + existing_entries = self._async_current_entries() if existing_entries: updated = False for entry in existing_entries: @@ -148,7 +148,7 @@ class NestFlowHandler( """Handle a flow initialized by the user.""" if self.is_sdm_api(): # Reauth will update an existing entry - if self.hass.config_entries.async_entries(DOMAIN) and not self._reauth: + if self._async_current_entries() and not self._reauth: return self.async_abort(reason="single_instance_allowed") return await super().async_step_user(user_input) return await self.async_step_init(user_input) @@ -159,7 +159,7 @@ class NestFlowHandler( flows = self.hass.data.get(DATA_FLOW_IMPL, {}) - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") if not flows: @@ -229,7 +229,7 @@ class NestFlowHandler( """Import existing auth from Nest.""" assert not self.is_sdm_api(), "Step only supported for legacy API" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") config_path = info["nest_conf_path"] diff --git a/homeassistant/components/omnilogic/config_flow.py b/homeassistant/components/omnilogic/config_flow.py index e8fc947340f..d5239760fcc 100644 --- a/homeassistant/components/omnilogic/config_flow.py +++ b/homeassistant/components/omnilogic/config_flow.py @@ -29,7 +29,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): """Handle the initial step.""" errors = {} - config_entry = self.hass.config_entries.async_entries(DOMAIN) + config_entry = self._async_current_entries() if config_entry: return self.async_abort(reason="single_instance_allowed") diff --git a/homeassistant/components/opentherm_gw/config_flow.py b/homeassistant/components/opentherm_gw/config_flow.py index 3b3cc8fefdc..7c3bc8f8f6b 100644 --- a/homeassistant/components/opentherm_gw/config_flow.py +++ b/homeassistant/components/opentherm_gw/config_flow.py @@ -45,7 +45,7 @@ class OpenThermGwConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): device = info[CONF_DEVICE] gw_id = cv.slugify(info.get(CONF_ID, name)) - entries = [e.data for e in self.hass.config_entries.async_entries(DOMAIN)] + entries = [e.data for e in self._async_current_entries()] if gw_id in [e[CONF_ID] for e in entries]: return self._show_form({"base": "id_exists"}) diff --git a/homeassistant/components/point/config_flow.py b/homeassistant/components/point/config_flow.py index d12274f4f9a..3b9ba84fab5 100644 --- a/homeassistant/components/point/config_flow.py +++ b/homeassistant/components/point/config_flow.py @@ -51,7 +51,7 @@ class PointFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import(self, user_input=None): """Handle external yaml configuration.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="already_setup") self.flow_impl = DOMAIN @@ -62,7 +62,7 @@ class PointFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Handle a flow start.""" flows = self.hass.data.get(DATA_FLOW_IMPL, {}) - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="already_setup") if not flows: @@ -84,7 +84,7 @@ class PointFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_auth(self, user_input=None): """Create an entry for auth.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="external_setup") errors = {} @@ -123,7 +123,7 @@ class PointFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_code(self, code=None): """Received code for authentication.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="already_setup") if code is None: diff --git a/homeassistant/components/ps4/config_flow.py b/homeassistant/components/ps4/config_flow.py index 1084aca1e8b..1be879df58e 100644 --- a/homeassistant/components/ps4/config_flow.py +++ b/homeassistant/components/ps4/config_flow.py @@ -118,7 +118,7 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self.device_list = [device["host-ip"] for device in devices] # Check that devices found aren't configured per account. - entries = self.hass.config_entries.async_entries(DOMAIN) + entries = self._async_current_entries() if entries: # Retrieve device data from all entries if creds match. conf_devices = [ diff --git a/homeassistant/components/soma/config_flow.py b/homeassistant/components/soma/config_flow.py index fcc5b238d70..b696d583c04 100644 --- a/homeassistant/components/soma/config_flow.py +++ b/homeassistant/components/soma/config_flow.py @@ -59,6 +59,6 @@ class SomaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import(self, user_input=None): """Handle flow start from existing config section.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="already_setup") return await self.async_step_creation(user_input) diff --git a/homeassistant/components/somfy/config_flow.py b/homeassistant/components/somfy/config_flow.py index dd803f86af7..05d1720cf6d 100644 --- a/homeassistant/components/somfy/config_flow.py +++ b/homeassistant/components/somfy/config_flow.py @@ -20,7 +20,7 @@ class SomfyFlowHandler( async def async_step_user(self, user_input=None): """Handle a flow start.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") return await super().async_step_user(user_input) diff --git a/homeassistant/components/tellduslive/config_flow.py b/homeassistant/components/tellduslive/config_flow.py index c2c8a413ded..712f25560cd 100644 --- a/homeassistant/components/tellduslive/config_flow.py +++ b/homeassistant/components/tellduslive/config_flow.py @@ -53,7 +53,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user(self, user_input=None): """Let user select host or cloud.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="already_setup") if user_input is not None or len(self._hosts) == 1: @@ -125,7 +125,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import(self, user_input): """Import a config entry.""" - if self.hass.config_entries.async_entries(DOMAIN): + if self._async_current_entries(): return self.async_abort(reason="already_setup") self._scan_interval = user_input[KEY_SCAN_INTERVAL] diff --git a/homeassistant/components/transmission/config_flow.py b/homeassistant/components/transmission/config_flow.py index 90a4bac8cba..d5c63aa736f 100644 --- a/homeassistant/components/transmission/config_flow.py +++ b/homeassistant/components/transmission/config_flow.py @@ -54,7 +54,7 @@ class TransmissionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if user_input is not None: - for entry in self.hass.config_entries.async_entries(DOMAIN): + for entry in self._async_current_entries(): if ( entry.data[CONF_HOST] == user_input[CONF_HOST] and entry.data[CONF_PORT] == user_input[CONF_PORT] diff --git a/homeassistant/components/upnp/config_flow.py b/homeassistant/components/upnp/config_flow.py index cc1a2d8051a..8e2dfc1f43f 100644 --- a/homeassistant/components/upnp/config_flow.py +++ b/homeassistant/components/upnp/config_flow.py @@ -184,7 +184,7 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): ) # Handle devices changing their UDN, only allow a single - existing_entries = self.hass.config_entries.async_entries(DOMAIN) + existing_entries = self._async_current_entries() for config_entry in existing_entries: entry_hostname = config_entry.data.get(CONFIG_ENTRY_HOSTNAME) if entry_hostname == discovery[DISCOVERY_HOSTNAME]: diff --git a/homeassistant/components/vesync/__init__.py b/homeassistant/components/vesync/__init__.py index 6ae978eb4b8..9a79ca1fbb4 100644 --- a/homeassistant/components/vesync/__init__.py +++ b/homeassistant/components/vesync/__init__.py @@ -10,7 +10,6 @@ from homeassistant.helpers import config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send from .common import async_process_devices -from .config_flow import configured_instances from .const import ( DOMAIN, SERVICE_UPDATE_DEVS, @@ -46,7 +45,7 @@ async def async_setup(hass, config): if conf is None: return True - if not configured_instances(hass): + if not hass.config_entries.async_entries(DOMAIN): hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, diff --git a/homeassistant/components/vesync/config_flow.py b/homeassistant/components/vesync/config_flow.py index 31455468ceb..f91848c5238 100644 --- a/homeassistant/components/vesync/config_flow.py +++ b/homeassistant/components/vesync/config_flow.py @@ -11,12 +11,6 @@ from homeassistant.core import callback from .const import DOMAIN -@callback -def configured_instances(hass): - """Return already configured instances.""" - return hass.config_entries.async_entries(DOMAIN) - - class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Handle a config flow.""" @@ -45,7 +39,7 @@ class VeSyncFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user(self, user_input=None): """Handle a flow start.""" - if configured_instances(self.hass): + if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") if not user_input: diff --git a/homeassistant/components/vizio/config_flow.py b/homeassistant/components/vizio/config_flow.py index 545ab87f47a..c1aba99d84b 100644 --- a/homeassistant/components/vizio/config_flow.py +++ b/homeassistant/components/vizio/config_flow.py @@ -278,7 +278,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import(self, import_config: dict[str, Any]) -> FlowResult: """Import a config entry from configuration.yaml.""" # Check if new config entry matches any existing config entries - for entry in self.hass.config_entries.async_entries(DOMAIN): + for entry in self._async_current_entries(): # If source is ignore bypass host check and continue through loop if entry.source == SOURCE_IGNORE: continue diff --git a/homeassistant/components/withings/config_flow.py b/homeassistant/components/withings/config_flow.py index 59c2d741269..29c1e162ed4 100644 --- a/homeassistant/components/withings/config_flow.py +++ b/homeassistant/components/withings/config_flow.py @@ -59,7 +59,7 @@ class WithingsFlowHandler( if profile: existing_entries = [ config_entry - for config_entry in self.hass.config_entries.async_entries(const.DOMAIN) + for config_entry in self._async_current_entries() if slugify(config_entry.data.get(const.PROFILE)) == slugify(profile) ] diff --git a/tests/components/hlk_sw16/test_config_flow.py b/tests/components/hlk_sw16/test_config_flow.py index 6a13fae70dc..7a57bc20417 100644 --- a/tests/components/hlk_sw16/test_config_flow.py +++ b/tests/components/hlk_sw16/test_config_flow.py @@ -104,9 +104,8 @@ async def test_form(hass): conf, ) - assert result4["type"] == "form" - assert result4["errors"] == {"base": "already_configured"} - await hass.async_block_till_done() + assert result4["type"] == "abort" + assert result4["reason"] == "already_configured" async def test_import(hass):