mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Rename HelperFlowStep to HelperFlowFormStep (#68583)
This commit is contained in:
parent
29a43cef0b
commit
c44d7205cf
@ -18,8 +18,8 @@ from homeassistant.const import (
|
||||
from homeassistant.helpers import selector
|
||||
from homeassistant.helpers.helper_config_entry_flow import (
|
||||
HelperConfigFlowHandler,
|
||||
HelperFlowFormStep,
|
||||
HelperFlowMenuStep,
|
||||
HelperFlowStep,
|
||||
)
|
||||
|
||||
from .const import (
|
||||
@ -78,12 +78,12 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
}
|
||||
).extend(OPTIONS_SCHEMA.schema)
|
||||
|
||||
CONFIG_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowStep(CONFIG_SCHEMA)
|
||||
CONFIG_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowFormStep(CONFIG_SCHEMA)
|
||||
}
|
||||
|
||||
OPTIONS_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowStep(OPTIONS_SCHEMA)
|
||||
OPTIONS_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowFormStep(OPTIONS_SCHEMA)
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,8 +11,8 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er, selector
|
||||
from homeassistant.helpers.helper_config_entry_flow import (
|
||||
HelperConfigFlowHandler,
|
||||
HelperFlowFormStep,
|
||||
HelperFlowMenuStep,
|
||||
HelperFlowStep,
|
||||
)
|
||||
|
||||
from . import DOMAIN
|
||||
@ -82,29 +82,29 @@ def set_group_type(group_type: str) -> Callable[[dict[str, Any]], dict[str, Any]
|
||||
return _set_group_type
|
||||
|
||||
|
||||
CONFIG_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
CONFIG_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowMenuStep(GROUP_TYPES),
|
||||
"binary_sensor": HelperFlowStep(
|
||||
"binary_sensor": HelperFlowFormStep(
|
||||
BINARY_SENSOR_CONFIG_SCHEMA, set_group_type("binary_sensor")
|
||||
),
|
||||
"cover": HelperFlowStep(
|
||||
"cover": HelperFlowFormStep(
|
||||
basic_group_config_schema("cover"), set_group_type("cover")
|
||||
),
|
||||
"fan": HelperFlowStep(basic_group_config_schema("fan"), set_group_type("fan")),
|
||||
"light": HelperFlowStep(LIGHT_CONFIG_SCHEMA, set_group_type("light")),
|
||||
"media_player": HelperFlowStep(
|
||||
"fan": HelperFlowFormStep(basic_group_config_schema("fan"), set_group_type("fan")),
|
||||
"light": HelperFlowFormStep(LIGHT_CONFIG_SCHEMA, set_group_type("light")),
|
||||
"media_player": HelperFlowFormStep(
|
||||
basic_group_config_schema("media_player"), set_group_type("media_player")
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
OPTIONS_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowStep(None, next_step=choose_options_step),
|
||||
"binary_sensor": HelperFlowStep(BINARY_SENSOR_OPTIONS_SCHEMA),
|
||||
"cover": HelperFlowStep(basic_group_options_schema("cover")),
|
||||
"fan": HelperFlowStep(basic_group_options_schema("fan")),
|
||||
"light": HelperFlowStep(LIGHT_OPTIONS_SCHEMA),
|
||||
"media_player": HelperFlowStep(basic_group_options_schema("media_player")),
|
||||
OPTIONS_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowFormStep(None, next_step=choose_options_step),
|
||||
"binary_sensor": HelperFlowFormStep(BINARY_SENSOR_OPTIONS_SCHEMA),
|
||||
"cover": HelperFlowFormStep(basic_group_options_schema("cover")),
|
||||
"fan": HelperFlowFormStep(basic_group_options_schema("fan")),
|
||||
"light": HelperFlowFormStep(LIGHT_OPTIONS_SCHEMA),
|
||||
"media_player": HelperFlowFormStep(basic_group_options_schema("media_player")),
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,8 +18,8 @@ from homeassistant.const import (
|
||||
from homeassistant.helpers import selector
|
||||
from homeassistant.helpers.helper_config_entry_flow import (
|
||||
HelperConfigFlowHandler,
|
||||
HelperFlowFormStep,
|
||||
HelperFlowMenuStep,
|
||||
HelperFlowStep,
|
||||
)
|
||||
|
||||
from .const import (
|
||||
@ -88,12 +88,12 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
}
|
||||
)
|
||||
|
||||
CONFIG_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowStep(CONFIG_SCHEMA)
|
||||
CONFIG_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowFormStep(CONFIG_SCHEMA)
|
||||
}
|
||||
|
||||
OPTIONS_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowStep(OPTIONS_SCHEMA)
|
||||
OPTIONS_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowFormStep(OPTIONS_SCHEMA)
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,15 +10,15 @@ from homeassistant.const import CONF_ENTITY_ID, Platform
|
||||
from homeassistant.helpers import entity_registry as er, selector
|
||||
from homeassistant.helpers.helper_config_entry_flow import (
|
||||
HelperConfigFlowHandler,
|
||||
HelperFlowFormStep,
|
||||
HelperFlowMenuStep,
|
||||
HelperFlowStep,
|
||||
wrapped_entity_config_entry_title,
|
||||
)
|
||||
|
||||
from .const import CONF_TARGET_DOMAIN, DOMAIN
|
||||
|
||||
CONFIG_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowStep(
|
||||
CONFIG_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowFormStep(
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_ENTITY_ID): selector.selector(
|
||||
|
@ -11,8 +11,8 @@ from homeassistant.helpers import selector
|
||||
from homeassistant.helpers.helper_config_entry_flow import (
|
||||
HelperConfigFlowHandler,
|
||||
HelperFlowError,
|
||||
HelperFlowFormStep,
|
||||
HelperFlowMenuStep,
|
||||
HelperFlowStep,
|
||||
)
|
||||
|
||||
from .const import CONF_HYSTERESIS, CONF_LOWER, CONF_UPPER, DEFAULT_HYSTERESIS, DOMAIN
|
||||
@ -44,12 +44,12 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
}
|
||||
).extend(OPTIONS_SCHEMA.schema)
|
||||
|
||||
CONFIG_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowStep(CONFIG_SCHEMA, validate_user_input=_validate_mode)
|
||||
CONFIG_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowFormStep(CONFIG_SCHEMA, validate_user_input=_validate_mode)
|
||||
}
|
||||
|
||||
OPTIONS_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowStep(OPTIONS_SCHEMA, validate_user_input=_validate_mode)
|
||||
OPTIONS_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowFormStep(OPTIONS_SCHEMA, validate_user_input=_validate_mode)
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ class HelperFlowError(Exception):
|
||||
|
||||
|
||||
@dataclass
|
||||
class HelperFlowStep:
|
||||
class HelperFlowFormStep:
|
||||
"""Define a helper config or options flow step."""
|
||||
|
||||
# Optional schema for requesting and validating user input. If schema validation
|
||||
@ -57,7 +57,7 @@ class HelperCommonFlowHandler:
|
||||
def __init__(
|
||||
self,
|
||||
handler: HelperConfigFlowHandler | HelperOptionsFlowHandler,
|
||||
flow: dict[str, HelperFlowStep | HelperFlowMenuStep],
|
||||
flow: dict[str, HelperFlowFormStep | HelperFlowMenuStep],
|
||||
config_entry: config_entries.ConfigEntry | None,
|
||||
) -> None:
|
||||
"""Initialize a common handler."""
|
||||
@ -69,7 +69,7 @@ class HelperCommonFlowHandler:
|
||||
self, step_id: str, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a step."""
|
||||
if isinstance(self._flow[step_id], HelperFlowStep):
|
||||
if isinstance(self._flow[step_id], HelperFlowFormStep):
|
||||
return await self._async_form_step(step_id, user_input)
|
||||
return await self._async_menu_step(step_id, user_input)
|
||||
|
||||
@ -77,7 +77,7 @@ class HelperCommonFlowHandler:
|
||||
self, step_id: str, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a form step."""
|
||||
form_step: HelperFlowStep = cast(HelperFlowStep, self._flow[step_id])
|
||||
form_step: HelperFlowFormStep = cast(HelperFlowFormStep, self._flow[step_id])
|
||||
|
||||
if user_input is not None and form_step.schema is not None:
|
||||
# Do extra validation of user input
|
||||
@ -109,7 +109,9 @@ class HelperCommonFlowHandler:
|
||||
user_input: dict[str, Any] | None = None,
|
||||
) -> FlowResult:
|
||||
"""Show form for next step."""
|
||||
form_step: HelperFlowStep = cast(HelperFlowStep, self._flow[next_step_id])
|
||||
form_step: HelperFlowFormStep = cast(
|
||||
HelperFlowFormStep, self._flow[next_step_id]
|
||||
)
|
||||
|
||||
options = dict(self._options)
|
||||
if user_input:
|
||||
@ -147,8 +149,8 @@ class HelperCommonFlowHandler:
|
||||
class HelperConfigFlowHandler(config_entries.ConfigFlow):
|
||||
"""Handle a config flow for helper integrations."""
|
||||
|
||||
config_flow: dict[str, HelperFlowStep | HelperFlowMenuStep]
|
||||
options_flow: dict[str, HelperFlowStep | HelperFlowMenuStep] | None = None
|
||||
config_flow: dict[str, HelperFlowFormStep | HelperFlowMenuStep]
|
||||
options_flow: dict[str, HelperFlowFormStep | HelperFlowMenuStep] | None = None
|
||||
|
||||
VERSION = 1
|
||||
|
||||
|
@ -10,8 +10,8 @@ from homeassistant.const import CONF_ENTITY_ID
|
||||
from homeassistant.helpers import selector
|
||||
from homeassistant.helpers.helper_config_entry_flow import (
|
||||
HelperConfigFlowHandler,
|
||||
HelperFlowFormStep,
|
||||
HelperFlowMenuStep,
|
||||
HelperFlowStep,
|
||||
)
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -30,12 +30,12 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
}
|
||||
).extend(OPTIONS_SCHEMA.schema)
|
||||
|
||||
CONFIG_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowStep(CONFIG_SCHEMA)
|
||||
CONFIG_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"user": HelperFlowFormStep(CONFIG_SCHEMA)
|
||||
}
|
||||
|
||||
OPTIONS_FLOW: dict[str, HelperFlowStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowStep(OPTIONS_SCHEMA)
|
||||
OPTIONS_FLOW: dict[str, HelperFlowFormStep | HelperFlowMenuStep] = {
|
||||
"init": HelperFlowFormStep(OPTIONS_SCHEMA)
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user