1 """Config flow for Lidarr."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
8 from aiohttp
import ClientConnectorError
9 from aiopyarr
import exceptions
10 from aiopyarr.lidarr_client
import LidarrClient
11 import voluptuous
as vol
18 from .const
import DEFAULT_NAME, DOMAIN
22 """Handle a config flow for Lidarr."""
27 self, entry_data: Mapping[str, Any]
28 ) -> ConfigFlowResult:
29 """Handle configuration by re-auth."""
33 self, user_input: dict[str, str] |
None =
None
34 ) -> ConfigFlowResult:
35 """Confirm reauth dialog."""
36 if user_input
is not None:
43 self, user_input: dict[str, Any] |
None =
None
44 ) -> ConfigFlowResult:
45 """Handle a flow initiated by the user."""
48 if user_input
is not None:
51 user_input[CONF_API_KEY] = result[1]
52 except exceptions.ArrAuthenticationException:
53 errors = {
"base":
"invalid_auth"}
54 except (ClientConnectorError, exceptions.ArrConnectionException):
55 errors = {
"base":
"cannot_connect"}
56 except exceptions.ArrWrongAppException:
57 errors = {
"base":
"wrong_app"}
58 except exceptions.ArrZeroConfException:
59 errors = {
"base":
"zeroconf_failed"}
60 except exceptions.ArrException:
61 errors = {
"base":
"unknown"}
70 if user_input
is None:
77 data_schema=vol.Schema(
79 vol.Required(CONF_URL, default=user_input.get(CONF_URL,
"")): str,
80 vol.Optional(CONF_API_KEY): str,
83 default=user_input.get(CONF_VERIFY_SSL,
False),
92 hass: HomeAssistant, data: dict[str, Any]
93 ) -> tuple[str, str, str] |
None:
94 """Validate the user input allows us to connect.
96 Data has the keys from DATA_SCHEMA with values provided by the user.
98 lidarr = LidarrClient(
99 api_token=data.get(CONF_API_KEY,
""),
102 verify_ssl=data[CONF_VERIFY_SSL],
104 if CONF_API_KEY
not in data:
105 return await lidarr.async_try_zeroconf()
106 await lidarr.async_get_system_status()
ConfigFlowResult async_step_reauth_confirm(self, dict[str, str]|None user_input=None)
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
ConfigFlowResult async_step_reauth(self, Mapping[str, Any] entry_data)
ConfigEntry _get_reauth_entry(self)
None _set_confirm_only(self)
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)
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)
tuple[str, str, str]|None validate_input(HomeAssistant hass, dict[str, Any] data)
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)