1 """Config flow for Balboa Spa Client integration."""
3 from __future__
import annotations
8 from pybalboa
import SpaClient
9 from pybalboa.exceptions
import SpaConnectionError
10 import voluptuous
as vol
19 SchemaOptionsFlowHandler,
22 from .const
import CONF_SYNC_TIME, DOMAIN
24 _LOGGER = logging.getLogger(__name__)
26 DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
28 OPTIONS_SCHEMA = vol.Schema(
30 vol.Required(CONF_SYNC_TIME, default=
False): bool,
39 """Validate the user input allows us to connect."""
40 _LOGGER.debug(
"Attempting to connect to %s", data[CONF_HOST])
42 async
with SpaClient(data[CONF_HOST])
as spa:
43 if not await spa.async_configuration_loaded():
47 except SpaConnectionError
as err:
48 raise CannotConnect
from err
50 return {
"title": model,
"formatted_mac": mac}
54 """Handle a Balboa Spa Client config flow."""
63 """Get the options flow for this handler."""
67 self, user_input: dict[str, Any] |
None =
None
68 ) -> ConfigFlowResult:
69 """Handle a flow initialized by the user."""
71 if user_input
is not None:
76 errors[
"base"] =
"cannot_connect"
78 _LOGGER.exception(
"Unexpected exception")
79 errors[
"base"] =
"unknown"
86 step_id=
"user", data_schema=DATA_SCHEMA, errors=errors
91 """Error to indicate we cannot connect."""
SchemaOptionsFlowHandler async_get_options_flow(ConfigEntry config_entry)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry|None async_set_unique_id(self, str|None unique_id=None, *bool raise_on_progress=True)
ConfigFlowResult async_create_entry(self, *str title, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None, Mapping[str, Any]|None options=None)
None _async_abort_entries_match(self, dict[str, Any]|None match_dict=None)
ConfigFlowResult async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_show_form(self, *str|None step_id=None, vol.Schema|None data_schema=None, dict[str, str]|None errors=None, Mapping[str, str]|None description_placeholders=None, bool|None last_step=None, str|None preview=None)
_FlowResultT async_create_entry(self, *str|None title=None, Mapping[str, Any] data, str|None description=None, Mapping[str, str]|None description_placeholders=None)
dict[str, str] validate_input(dict[str, Any] data)