1 """Config flow for Omnilogic integration."""
3 from __future__
import annotations
8 from omnilogic
import LoginException, OmniLogic, OmniLogicException
9 import voluptuous
as vol
21 from .const
import CONF_SCAN_INTERVAL, DEFAULT_PH_OFFSET, DEFAULT_SCAN_INTERVAL, DOMAIN
23 _LOGGER = logging.getLogger(__name__)
27 """Handle a config flow for Omnilogic."""
34 config_entry: ConfigEntry,
35 ) -> OptionsFlowHandler:
36 """Get the options flow for this handler."""
40 self, user_input: dict[str, Any] |
None =
None
41 ) -> ConfigFlowResult:
42 """Handle the initial step."""
43 errors: dict[str, str] = {}
45 if user_input
is not None:
46 username = user_input[CONF_USERNAME]
47 password = user_input[CONF_PASSWORD]
49 session = aiohttp_client.async_get_clientsession(self.hass)
50 omni = OmniLogic(username, password, session)
54 except LoginException:
55 errors[
"base"] =
"invalid_auth"
56 except OmniLogicException:
57 errors[
"base"] =
"cannot_connect"
59 _LOGGER.exception(
"Unexpected exception")
60 errors[
"base"] =
"unknown"
68 data_schema=vol.Schema(
70 vol.Required(CONF_USERNAME): str,
71 vol.Required(CONF_PASSWORD): str,
79 """Handle Omnilogic client options."""
82 self, user_input: dict[str, Any] |
None =
None
83 ) -> ConfigFlowResult:
86 if user_input
is not None:
91 data_schema=vol.Schema(
96 CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL
102 "ph_offset", DEFAULT_PH_OFFSET
104 ): vol.All(vol.Coerce(float)),
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
OptionsFlowHandler async_get_options_flow(ConfigEntry config_entry)
ConfigFlowResult async_step_init(self, dict[str, Any]|None user_input=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)
ConfigEntry config_entry(self)
None config_entry(self, ConfigEntry value)
_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)