1 """Config flow for Rainforest Eagle integration."""
3 from __future__
import annotations
8 import voluptuous
as vol
13 from .const
import CONF_CLOUD_ID, CONF_HARDWARE_ADDRESS, CONF_INSTALL_CODE, DOMAIN
14 from .data
import CannotConnect, InvalidAuth, async_get_type
16 _LOGGER = logging.getLogger(__name__)
20 """Create user schema with passed in defaults if available."""
21 if user_input
is None:
25 vol.Required(CONF_HOST, default=user_input.get(CONF_HOST)): str,
26 vol.Required(CONF_CLOUD_ID, default=user_input.get(CONF_CLOUD_ID)): str,
28 CONF_INSTALL_CODE, default=user_input.get(CONF_INSTALL_CODE)
35 """Handle a config flow for Rainforest Eagle."""
40 self, user_input: dict[str, Any] |
None =
None
41 ) -> ConfigFlowResult:
42 """Handle the initial step."""
43 if user_input
is None:
54 user_input[CONF_CLOUD_ID],
55 user_input[CONF_INSTALL_CODE],
56 user_input[CONF_HOST],
59 errors[
"base"] =
"cannot_connect"
61 errors[
"base"] =
"invalid_auth"
63 _LOGGER.exception(
"Unexpected exception")
64 errors[
"base"] =
"unknown"
66 user_input[CONF_TYPE] = eagle_type
67 user_input[CONF_HARDWARE_ADDRESS] = hardware_address
69 title=user_input[CONF_CLOUD_ID], data=user_input
73 step_id=
"user", data_schema=
create_schema(user_input), errors=errors
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
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)
vol.Schema create_schema(dict[str, Any]|None user_input)
def async_get_type(hass, cloud_id, install_code, host)