1 """Config flow utilities."""
5 from pyvesync
import VeSync
6 import voluptuous
as vol
13 from .const
import DOMAIN
15 DATA_SCHEMA = vol.Schema(
17 vol.Required(CONF_USERNAME): cv.string,
18 vol.Required(CONF_PASSWORD): cv.string,
24 """Handle a config flow."""
29 def _show_form(self, errors: dict[str, str] |
None =
None) -> ConfigFlowResult:
30 """Show form to the user."""
33 data_schema=DATA_SCHEMA,
34 errors=errors
if errors
else {},
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle a flow start."""
47 username = user_input[CONF_USERNAME]
48 password = user_input[CONF_PASSWORD]
50 manager = VeSync(username, password)
51 login = await self.hass.async_add_executor_job(manager.login)
53 return self.
_show_form_show_form(errors={
"base":
"invalid_auth"})
57 data={CONF_USERNAME: username, CONF_PASSWORD: password},
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult _show_form(self, dict[str, str]|None errors=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)
list[ConfigEntry] _async_current_entries(self, bool|None include_ignore=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)