1 """Config flow to configure the PVOutput integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 from pvo
import PVOutput, PVOutputAuthenticationError, PVOutputError
9 import voluptuous
as vol
16 from .const
import CONF_SYSTEM_ID, DOMAIN, LOGGER
19 async
def validate_input(hass: HomeAssistant, *, api_key: str, system_id: int) ->
None:
20 """Try using the give system id & api key against the PVOutput API."""
27 await pvoutput.system()
31 """Config flow for PVOutput."""
35 imported_name: str |
None =
None
38 self, user_input: dict[str, Any] |
None =
None
39 ) -> ConfigFlowResult:
40 """Handle a flow initialized by the user."""
43 if user_input
is not None:
47 api_key=user_input[CONF_API_KEY],
48 system_id=user_input[CONF_SYSTEM_ID],
50 except PVOutputAuthenticationError:
51 errors[
"base"] =
"invalid_auth"
53 LOGGER.exception(
"Cannot connect to PVOutput")
54 errors[
"base"] =
"cannot_connect"
59 title=self.imported_name
or str(user_input[CONF_SYSTEM_ID]),
61 CONF_SYSTEM_ID: user_input[CONF_SYSTEM_ID],
62 CONF_API_KEY: user_input[CONF_API_KEY],
70 description_placeholders={
71 "account_url":
"https://pvoutput.org/account.jsp"
73 data_schema=vol.Schema(
76 CONF_API_KEY, default=user_input.get(CONF_API_KEY,
"")
79 CONF_SYSTEM_ID, default=user_input.get(CONF_SYSTEM_ID,
"")
86 async
def async_step_reauth(
87 self, entry_data: Mapping[str, Any]
88 ) -> ConfigFlowResult:
89 """Handle initiation of re-authentication with PVOutput."""
90 return await self.async_step_reauth_confirm()
92 async
def async_step_reauth_confirm(
93 self, user_input: dict[str, Any] |
None =
None
94 ) -> ConfigFlowResult:
95 """Handle re-authentication with PVOutput."""
98 if user_input
is not None:
103 api_key=user_input[CONF_API_KEY],
104 system_id=reauth_entry.data[CONF_SYSTEM_ID],
106 except PVOutputAuthenticationError:
107 errors[
"base"] =
"invalid_auth"
108 except PVOutputError:
109 errors[
"base"] =
"cannot_connect"
112 reauth_entry, data_updates=user_input
116 step_id=
"reauth_confirm",
117 description_placeholders={
118 "account_url":
"https://pvoutput.org/account.jsp"
120 data_schema=vol.Schema({vol.Required(CONF_API_KEY): str}),
ConfigFlowResult async_step_user(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 _get_reauth_entry(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_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_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)
None validate_input(HomeAssistant hass, *str api_key, int system_id)
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)