1 """Config flows for the ENOcean integration."""
5 import voluptuous
as vol
11 from .const
import DOMAIN, ERROR_INVALID_DONGLE_PATH, LOGGER
15 """Handle the enOcean config flows."""
18 MANUAL_PATH_VALUE =
"Custom path"
21 """Initialize the EnOcean config flow."""
26 """Import a yaml configuration."""
30 "Cannot import yaml configuration: %s is not a valid dongle path",
31 import_data[CONF_DEVICE],
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle an EnOcean config flow start."""
44 self, user_input: dict[str, Any] |
None =
None
45 ) -> ConfigFlowResult:
46 """Propose a list of detected dongles."""
48 if user_input
is not None:
53 errors = {CONF_DEVICE: ERROR_INVALID_DONGLE_PATH}
55 bridges = await self.hass.async_add_executor_job(dongle.detect)
62 data_schema=vol.Schema({vol.Required(CONF_DEVICE): vol.In(bridges)}),
67 self, user_input: dict[str, Any] |
None =
None
68 ) -> ConfigFlowResult:
69 """Request manual USB dongle path."""
72 if user_input
is not None:
75 default_value = user_input[CONF_DEVICE]
76 errors = {CONF_DEVICE: ERROR_INVALID_DONGLE_PATH}
80 data_schema=vol.Schema(
81 {vol.Required(CONF_DEVICE, default=default_value): str}
87 """Return True if the user_input contains a valid dongle path."""
88 dongle_path = user_input[CONF_DEVICE]
89 return await self.hass.async_add_executor_job(dongle.validate_path, dongle_path)
92 """Create an entry for the provided configuration."""
ConfigFlowResult async_step_manual(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_detect(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
def create_enocean_entry(self, user_input)
bool validate_enocean_conf(self, user_input)
ConfigFlowResult async_step_import(self, dict[str, Any] import_data)
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_abort(self, *str reason, Mapping[str, str]|None description_placeholders=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)
_FlowResultT async_abort(self, *str reason, Mapping[str, str]|None description_placeholders=None)