1 """Config flow for StreamLabs integration."""
3 from __future__
import annotations
7 from streamlabswater.streamlabswater
import StreamlabsClient
8 import voluptuous
as vol
15 from .const
import DOMAIN, LOGGER
19 """Validate the user input allows us to connect."""
20 client = StreamlabsClient(api_key)
21 response = await hass.async_add_executor_job(client.get_locations)
22 locations = response.get(
"locations")
29 """Handle a config flow for StreamLabs."""
34 self, user_input: dict[str, Any] |
None =
None
35 ) -> ConfigFlowResult:
36 """Handle the initial step."""
37 errors: dict[str, str] = {}
38 if user_input
is not None:
43 errors[
"base"] =
"cannot_connect"
45 LOGGER.exception(
"Unexpected exception")
46 errors[
"base"] =
"unknown"
52 data_schema=vol.Schema(
54 vol.Required(CONF_API_KEY): str,
62 """Error to indicate we cannot connect."""
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)
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)
None validate_input(HomeAssistant hass, str api_key)