Standardize import step variable name (part 4) (#124692)
* Standardize import step variable name (part 4) * One more * Revert geonetnz_volcano * Revert SMS due to coverage * Revert somfy_mylink due to coverage
This commit is contained in:
parent
f802611359
commit
318259689f
16 changed files with 50 additions and 46 deletions
|
@ -314,10 +314,10 @@ class BroadlinkFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
step_id="finish", data_schema=vol.Schema(data_schema), errors=errors
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_info):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a device."""
|
||||
self._async_abort_entries_match({CONF_HOST: import_info[CONF_HOST]})
|
||||
return await self.async_step_user(import_info)
|
||||
self._async_abort_entries_match({CONF_HOST: import_data[CONF_HOST]})
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
|
|
|
@ -80,7 +80,7 @@ class EcobeeFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
description_placeholders={"pin": self._ecobee.pin},
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_data):
|
||||
async def async_step_import(self, import_data: None) -> ConfigFlowResult:
|
||||
"""Import ecobee config from configuration.yaml.
|
||||
|
||||
Triggered by async_setup only if a config entry doesn't already exist.
|
||||
|
|
|
@ -56,6 +56,6 @@ class EmulatedRokuFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_config):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle a flow import."""
|
||||
return await self.async_step_user(import_config)
|
||||
return await self.async_step_user(import_data)
|
||||
|
|
|
@ -45,9 +45,9 @@ class GeonetnzQuakesFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
step_id="user", data_schema=DATA_SCHEMA, errors=errors or {}
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_config):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a config entry from configuration.yaml."""
|
||||
return await self.async_step_user(import_config)
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Config flow for google assistant component."""
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
|
||||
from .const import CONF_PROJECT_ID, DOMAIN
|
||||
|
||||
|
@ -10,10 +12,10 @@ class GoogleAssistantHandler(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_import(self, user_input):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a config entry."""
|
||||
await self.async_set_unique_id(unique_id=user_input[CONF_PROJECT_ID])
|
||||
await self.async_set_unique_id(unique_id=import_data[CONF_PROJECT_ID])
|
||||
self._abort_if_unique_id_configured()
|
||||
return self.async_create_entry(
|
||||
title=user_input[CONF_PROJECT_ID], data=user_input
|
||||
title=import_data[CONF_PROJECT_ID], data=import_data
|
||||
)
|
||||
|
|
|
@ -82,7 +82,7 @@ class HabiticaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
description_placeholders={},
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_data):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import habitica config from configuration.yaml."""
|
||||
|
||||
async_create_issue(
|
||||
|
|
|
@ -70,9 +70,9 @@ class SW16FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_import(self, user_input):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle import."""
|
||||
return await self.async_step_user(user_input)
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
|
|
|
@ -69,9 +69,9 @@ class JuiceNetConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_import(self, user_input):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle import."""
|
||||
return await self.async_step_user(user_input)
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
|
||||
class CannotConnect(exceptions.HomeAssistantError):
|
||||
|
|
|
@ -226,12 +226,12 @@ class KodiConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
return self._show_ws_port_form(errors)
|
||||
|
||||
async def async_step_import(self, data):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle import from YAML."""
|
||||
reason = None
|
||||
try:
|
||||
await validate_http(self.hass, data)
|
||||
await validate_ws(self.hass, data)
|
||||
await validate_http(self.hass, import_data)
|
||||
await validate_ws(self.hass, import_data)
|
||||
except InvalidAuth:
|
||||
_LOGGER.exception("Invalid Kodi credentials")
|
||||
reason = "invalid_auth"
|
||||
|
@ -242,7 +242,9 @@ class KodiConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
_LOGGER.exception("Unexpected exception")
|
||||
reason = "unknown"
|
||||
else:
|
||||
return self.async_create_entry(title=data[CONF_NAME], data=data)
|
||||
return self.async_create_entry(
|
||||
title=import_data[CONF_NAME], data=import_data
|
||||
)
|
||||
|
||||
return self.async_abort(reason=reason)
|
||||
|
||||
|
|
|
@ -202,24 +202,24 @@ class KonnectedFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
random.choices(f"{string.ascii_uppercase}{string.digits}", k=20)
|
||||
)
|
||||
|
||||
async def async_step_import(self, device_config):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a configuration.yaml config.
|
||||
|
||||
This flow is triggered by `async_setup` for configured panels.
|
||||
"""
|
||||
_LOGGER.debug(device_config)
|
||||
_LOGGER.debug(import_data)
|
||||
|
||||
# save the data and confirm connection via user step
|
||||
await self.async_set_unique_id(device_config["id"])
|
||||
self.options = device_config[CONF_DEFAULT_OPTIONS]
|
||||
await self.async_set_unique_id(import_data["id"])
|
||||
self.options = import_data[CONF_DEFAULT_OPTIONS]
|
||||
|
||||
# config schema ensures we have port if we have host
|
||||
if device_config.get(CONF_HOST):
|
||||
if import_data.get(CONF_HOST):
|
||||
# automatically connect if we have host info
|
||||
return await self.async_step_user(
|
||||
user_input={
|
||||
CONF_HOST: device_config[CONF_HOST],
|
||||
CONF_PORT: device_config[CONF_PORT],
|
||||
CONF_HOST: import_data[CONF_HOST],
|
||||
CONF_PORT: import_data[CONF_PORT],
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -166,21 +166,21 @@ class LutronCasetaFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
for asset_key, conf_key in FILE_MAPPING.items():
|
||||
self.data[conf_key] = TLS_ASSET_TEMPLATE.format(self.bridge_id, asset_key)
|
||||
|
||||
async def async_step_import(self, import_info):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a new Caseta bridge as a config entry.
|
||||
|
||||
This flow is triggered by `async_setup`.
|
||||
"""
|
||||
host = import_info[CONF_HOST]
|
||||
host = import_data[CONF_HOST]
|
||||
# Store the imported config for other steps in this flow to access.
|
||||
self.data[CONF_HOST] = host
|
||||
|
||||
# Abort if existing entry with matching host exists.
|
||||
self._async_abort_entries_match({CONF_HOST: self.data[CONF_HOST]})
|
||||
|
||||
self.data[CONF_KEYFILE] = import_info[CONF_KEYFILE]
|
||||
self.data[CONF_CERTFILE] = import_info[CONF_CERTFILE]
|
||||
self.data[CONF_CA_CERTS] = import_info[CONF_CA_CERTS]
|
||||
self.data[CONF_KEYFILE] = import_data[CONF_KEYFILE]
|
||||
self.data[CONF_CERTFILE] = import_data[CONF_CERTFILE]
|
||||
self.data[CONF_CA_CERTS] = import_data[CONF_CA_CERTS]
|
||||
|
||||
if not (lutron_id := await self.async_get_lutron_id()):
|
||||
# Ultimately we won't have a dedicated step for import failure, but
|
||||
|
|
|
@ -160,9 +160,9 @@ class OctoPrintConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
"""Handle api fetch failure."""
|
||||
return self.async_abort(reason="auth_failed")
|
||||
|
||||
async def async_step_import(self, user_input):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Handle import."""
|
||||
return await self.async_step_user(user_input)
|
||||
return await self.async_step_user(import_data)
|
||||
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
|
|
|
@ -92,15 +92,15 @@ class OpenThermGwConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
"""Handle manual initiation of the config flow."""
|
||||
return await self.async_step_init(user_input)
|
||||
|
||||
async def async_step_import(self, import_config):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import an OpenTherm Gateway device as a config entry.
|
||||
|
||||
This flow is triggered by `async_setup` for configured devices.
|
||||
"""
|
||||
formatted_config = {
|
||||
CONF_NAME: import_config.get(CONF_NAME, import_config[CONF_ID]),
|
||||
CONF_DEVICE: import_config[CONF_DEVICE],
|
||||
CONF_ID: import_config[CONF_ID],
|
||||
CONF_NAME: import_data.get(CONF_NAME, import_data[CONF_ID]),
|
||||
CONF_DEVICE: import_data[CONF_DEVICE],
|
||||
CONF_ID: import_data[CONF_ID],
|
||||
}
|
||||
return await self.async_step_init(info=formatted_config)
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class SABnzbdConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_data):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import sabnzbd config from configuration.yaml."""
|
||||
protocol = "https://" if import_data[CONF_SSL] else "http://"
|
||||
import_data[CONF_URL] = (
|
||||
|
|
|
@ -82,6 +82,6 @@ class SpiderConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
errors=errors,
|
||||
)
|
||||
|
||||
async def async_step_import(self, import_data):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import spider config from configuration.yaml."""
|
||||
return await self.async_step_user(import_data)
|
||||
|
|
|
@ -125,14 +125,14 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_step_import(self, user_input):
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import a config entry."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="already_setup")
|
||||
|
||||
self._scan_interval = user_input[KEY_SCAN_INTERVAL]
|
||||
if user_input[CONF_HOST] != DOMAIN:
|
||||
self._hosts.append(user_input[CONF_HOST])
|
||||
self._scan_interval = import_data[KEY_SCAN_INTERVAL]
|
||||
if import_data[CONF_HOST] != DOMAIN:
|
||||
self._hosts.append(import_data[CONF_HOST])
|
||||
|
||||
if not await self.hass.async_add_executor_job(
|
||||
os.path.isfile, self.hass.config.path(TELLDUS_CONFIG_FILE)
|
||||
|
@ -144,7 +144,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
)
|
||||
host = next(iter(conf))
|
||||
|
||||
if user_input[CONF_HOST] != host:
|
||||
if import_data[CONF_HOST] != host:
|
||||
return await self.async_step_user()
|
||||
|
||||
host = CLOUD_NAME if host == "tellduslive" else host
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue