1 """Config flow for Plum Lightpad."""
3 from __future__
import annotations
8 from aiohttp
import ContentTypeError
9 from requests.exceptions
import ConnectTimeout, HTTPError
10 import voluptuous
as vol
15 from .const
import DOMAIN
16 from .utils
import load_plum
18 _LOGGER = logging.getLogger(__name__)
22 """Config flow for Plum Lightpad integration."""
28 vol.Required(CONF_USERNAME): str,
29 vol.Required(CONF_PASSWORD): str,
34 data_schema=vol.Schema(schema),
39 self, user_input: dict[str, Any] |
None =
None
40 ) -> ConfigFlowResult:
41 """Handle a flow initialized by the user or redirected to by import."""
45 username = user_input[CONF_USERNAME]
46 password = user_input[CONF_PASSWORD]
50 await
load_plum(username, password, self.hass)
51 except (ContentTypeError, ConnectTimeout, HTTPError)
as ex:
52 _LOGGER.error(
"Unable to connect/authenticate to Plum cloud: %s",
str(ex))
53 return self.
_show_form_show_form({
"base":
"cannot_connect"})
59 title=username, data={CONF_USERNAME: username, CONF_PASSWORD: password}
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
def _show_form(self, errors=None)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry|None async_set_unique_id(self, str|None unique_id=None, *bool raise_on_progress=True)
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_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)
Plum load_plum(str username, str password, HomeAssistant hass)