Avoid access to `self.context["source"]` in integration config flows (#132355)
* Avoid access to `self.context["source"]` in integration config flows * One more * One morepull/132457/head
parent
b2ac16e95f
commit
b1379f6a89
|
@ -74,7 +74,7 @@ class CertexpiryConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
title=title,
|
||||
data={CONF_HOST: host, CONF_PORT: port},
|
||||
)
|
||||
if self.context["source"] == SOURCE_IMPORT:
|
||||
if self.source == SOURCE_IMPORT:
|
||||
_LOGGER.error("Config import failed for %s", user_input[CONF_HOST])
|
||||
return self.async_abort(reason="import_failed")
|
||||
else:
|
||||
|
|
|
@ -104,7 +104,7 @@ class HiveFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
errors["base"] = "no_internet_available"
|
||||
|
||||
if not errors:
|
||||
if self.context["source"] == SOURCE_REAUTH:
|
||||
if self.source == SOURCE_REAUTH:
|
||||
return await self.async_setup_hive_entry()
|
||||
self.device_registration = True
|
||||
return await self.async_step_configuration()
|
||||
|
@ -144,7 +144,7 @@ class HiveFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
# Setup the config entry
|
||||
self.data["tokens"] = self.tokens
|
||||
if self.context["source"] == SOURCE_REAUTH:
|
||||
if self.source == SOURCE_REAUTH:
|
||||
assert self.entry
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self.entry, title=self.data["username"], data=self.data
|
||||
|
|
|
@ -231,7 +231,7 @@ class VizioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
errors[CONF_HOST] = "existing_config_entry_found"
|
||||
|
||||
if not errors:
|
||||
if self._must_show_form and self.context["source"] == SOURCE_ZEROCONF:
|
||||
if self._must_show_form and self.source == SOURCE_ZEROCONF:
|
||||
# Discovery should always display the config form before trying to
|
||||
# create entry so that user can update default config options
|
||||
self._must_show_form = False
|
||||
|
@ -251,7 +251,7 @@ class VizioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
if not errors:
|
||||
return await self._create_entry(user_input)
|
||||
elif self._must_show_form and self.context["source"] == SOURCE_IMPORT:
|
||||
elif self._must_show_form and self.source == SOURCE_IMPORT:
|
||||
# Import should always display the config form if CONF_ACCESS_TOKEN
|
||||
# wasn't included but is needed so that the user can choose to update
|
||||
# their configuration.yaml or to proceed with config flow pairing. We
|
||||
|
@ -272,7 +272,7 @@ class VizioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
schema = self._user_schema or _get_config_schema()
|
||||
|
||||
if errors and self.context["source"] == SOURCE_IMPORT:
|
||||
if errors and self.source == SOURCE_IMPORT:
|
||||
# Log an error message if import config flow fails since otherwise failure is silent
|
||||
_LOGGER.error(
|
||||
"Importing from configuration.yaml failed: %s",
|
||||
|
@ -434,7 +434,7 @@ class VizioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self._data[CONF_ACCESS_TOKEN] = pair_data.auth_token
|
||||
self._must_show_form = True
|
||||
|
||||
if self.context["source"] == SOURCE_IMPORT:
|
||||
if self.source == SOURCE_IMPORT:
|
||||
# If user is pairing via config import, show different message
|
||||
return await self.async_step_pairing_complete_import()
|
||||
|
||||
|
|
|
@ -671,7 +671,7 @@ class ZWaveJSConfigFlow(BaseZwaveJSFlow, ConfigFlow, domain=DOMAIN):
|
|||
discovery_info = await self._async_get_addon_discovery_info()
|
||||
self.ws_address = f"ws://{discovery_info['host']}:{discovery_info['port']}"
|
||||
|
||||
if not self.unique_id or self.context["source"] == SOURCE_USB:
|
||||
if not self.unique_id or self.source == SOURCE_USB:
|
||||
if not self.version_info:
|
||||
try:
|
||||
self.version_info = await async_get_version_info(
|
||||
|
|
Loading…
Reference in New Issue