1 """Config flow for Efergy integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 from pyefergy
import Efergy, exceptions
9 import voluptuous
as vol
15 from .const
import DEFAULT_NAME, DOMAIN, LOGGER
19 """Handle a config flow for Efergy."""
24 self, user_input: dict[str, Any] |
None =
None
25 ) -> ConfigFlowResult:
26 """Handle a flow initiated by the user."""
28 if user_input
is not None:
29 api_key = user_input[CONF_API_KEY]
40 data={CONF_API_KEY: api_key},
42 errors[
"base"] = error
46 data_schema=vol.Schema(
48 vol.Required(CONF_API_KEY): str,
55 self, entry_data: Mapping[str, Any]
56 ) -> ConfigFlowResult:
57 """Handle a reauthorization flow request."""
61 """Try connecting to Efergy servers."""
65 utc_offset=self.hass.config.time_zone,
68 await api.async_status()
69 except exceptions.ConnectError:
70 return None,
"cannot_connect"
71 except exceptions.InvalidAuth:
72 return None,
"invalid_auth"
74 LOGGER.exception(
"Unexpected exception")
75 return None,
"unknown"
76 return api.info[
"hid"],
None
tuple[str|None, str|None] _async_try_connect(self, str api_key)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
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_update_reload_and_abort(self, ConfigEntry entry, *str|None|UndefinedType unique_id=UNDEFINED, str|UndefinedType title=UNDEFINED, Mapping[str, Any]|UndefinedType data=UNDEFINED, Mapping[str, Any]|UndefinedType data_updates=UNDEFINED, Mapping[str, Any]|UndefinedType options=UNDEFINED, str|UndefinedType reason=UNDEFINED, bool reload_even_if_entry_is_unchanged=True)
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)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)