1 """Config flow for Bryant Evolution integration."""
3 from __future__
import annotations
8 from evolutionhttp
import BryantEvolutionLocalClient
9 import voluptuous
as vol
14 from .const
import CONF_SYSTEM_ZONE, DOMAIN
16 _LOGGER = logging.getLogger(__name__)
18 STEP_USER_DATA_SCHEMA = vol.Schema(
20 vol.Required(CONF_FILENAME, default=
"/dev/ttyUSB0"): str,
26 """Return (system, zone) tuples for each system+zone accessible through tty."""
28 (system_id, zone.zone_id)
29 for system_id
in (1, 2)
30 for zone
in await BryantEvolutionLocalClient.enumerate_zones(system_id, tty)
35 """Handle a config flow for Bryant Evolution."""
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle the initial step."""
41 errors: dict[str, str] = {}
42 if user_input
is not None:
45 except FileNotFoundError:
46 _LOGGER.error(
"Could not open %s: not found", user_input[CONF_FILENAME])
47 errors[
"base"] =
"cannot_connect"
49 if len(system_zone) != 0:
51 title=f
"SAM at {user_input[CONF_FILENAME]}",
53 CONF_FILENAME: user_input[CONF_FILENAME],
54 CONF_SYSTEM_ZONE: system_zone,
57 errors[
"base"] =
"cannot_connect"
59 step_id=
"user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
62 async
def async_step_reconfigure(
63 self, user_input: dict[str, Any] |
None =
None
64 ) -> ConfigFlowResult:
65 """Handle integration reconfiguration."""
66 errors: dict[str, str] = {}
67 if user_input
is not None:
69 if len(system_zone) != 0:
73 CONF_FILENAME: user_input[CONF_FILENAME],
74 CONF_SYSTEM_ZONE: system_zone,
77 errors[
"base"] =
"cannot_connect"
79 step_id=
"reconfigure",
80 data_schema=STEP_USER_DATA_SCHEMA,
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
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)
ConfigFlowResult async_update_reload_and_abort(self, ConfigEntry entry, *str|None|UndefinedType unique_id=UNDEFINED, str|UndefinedType title=UNDEFINED, Mapping[str, Any]|UndefinedType data=UNDEFINED, Mapping[str, Any]|UndefinedType data_updates=UNDEFINED, Mapping[str, Any]|UndefinedType options=UNDEFINED, str|UndefinedType reason=UNDEFINED, bool reload_even_if_entry_is_unchanged=True)
ConfigEntry _get_reconfigure_entry(self)
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)
list[tuple[int, int]] _enumerate_sz(str tty)