1 """Config flow to configure the Venstar integration."""
5 from venstarcolortouch
import VenstarColorTouch
6 import voluptuous
as vol
19 from .const
import _LOGGER, DOMAIN, VENSTAR_TIMEOUT
23 """Validate the user input allows us to connect."""
24 username = data.get(CONF_USERNAME)
25 password = data.get(CONF_PASSWORD)
26 pin = data.get(CONF_PIN)
27 host = data[CONF_HOST]
28 timeout = VENSTAR_TIMEOUT
29 protocol =
"https" if data[CONF_SSL]
else "http"
31 client = VenstarColorTouch(
42 info_success = await hass.async_add_executor_job(client.update_info)
50 """Handle a venstar config flow."""
55 self, user_input: dict[str, Any] |
None =
None
56 ) -> ConfigFlowResult:
57 """Create config entry. Show the setup form to the user."""
60 if user_input
is not None:
66 errors[
"base"] =
"cannot_connect"
68 _LOGGER.exception(
"Unexpected exception")
69 errors[
"base"] =
"unknown"
75 data_schema=vol.Schema(
77 vol.Required(CONF_HOST): str,
78 vol.Optional(CONF_USERNAME): str,
79 vol.Optional(CONF_PASSWORD): str,
80 vol.Optional(CONF_PIN): str,
81 vol.Optional(CONF_SSL, default=
False): bool,
88 """Import entry from configuration.yaml."""
92 CONF_HOST: import_data[CONF_HOST],
93 CONF_USERNAME: import_data.get(CONF_USERNAME),
94 CONF_PASSWORD: import_data.get(CONF_PASSWORD),
95 CONF_PIN: import_data.get(CONF_PIN),
96 CONF_SSL: import_data[CONF_SSL],
102 """Error to indicate we cannot connect."""
ConfigFlowResult async_step_import(self, dict[str, Any] import_data)
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_step_user(self, dict[str, Any]|None user_input=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)
str validate_input(HomeAssistant hass, dict[str, Any] data)