1 """Config flow for Goal Zero Yeti integration."""
3 from __future__
import annotations
8 from goalzero
import Yeti, exceptions
9 import voluptuous
as vol
17 from .const
import DEFAULT_NAME, DOMAIN, MANUFACTURER
19 _LOGGER = logging.getLogger(__name__)
23 """Handle a config flow for Goal Zero Yeti."""
30 self, discovery_info: dhcp.DhcpServiceInfo
31 ) -> ConfigFlowResult:
32 """Handle dhcp discovery."""
45 self, user_input: dict[str, Any] |
None =
None
46 ) -> ConfigFlowResult:
47 """Allow the user to confirm adding the device."""
48 if user_input
is not None:
53 CONF_NAME: DEFAULT_NAME,
59 step_id=
"confirm_discovery",
60 description_placeholders={
62 CONF_NAME: DEFAULT_NAME,
67 self, user_input: dict[str, Any] |
None =
None
68 ) -> ConfigFlowResult:
69 """Handle a flow initiated by the user."""
71 if user_input
is not None:
72 host = user_input[CONF_HOST]
73 name = user_input[CONF_NAME]
83 data={CONF_HOST: host, CONF_NAME: name},
85 errors[
"base"] = error
87 user_input = user_input
or {}
90 data_schema=vol.Schema(
93 CONF_HOST, default=user_input.get(CONF_HOST)
or ""
96 CONF_NAME, default=user_input.get(CONF_NAME)
or DEFAULT_NAME
104 """Try connecting to Goal Zero Yeti."""
108 except exceptions.ConnectError:
109 return None,
"cannot_connect"
110 except exceptions.InvalidHost:
111 return None,
"invalid_host"
113 _LOGGER.exception(
"Unexpected exception")
114 return None,
"unknown"
115 return str(api.sysdata[
"macAddress"]),
None
ConfigFlowResult async_step_dhcp(self, dhcp.DhcpServiceInfo discovery_info)
ConfigFlowResult async_step_confirm_discovery(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
tuple[str|None, str|None] _async_try_connect(self, str host)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
None _set_confirm_only(self)
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_abort(self, *str reason, Mapping[str, str]|None description_placeholders=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)
_FlowResultT async_abort(self, *str reason, 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)