1 """Config flow for qBittorrent."""
3 from __future__
import annotations
8 from qbittorrentapi
import APIConnectionError, Forbidden403Error, LoginFailed
9 import voluptuous
as vol
14 from .const
import DEFAULT_NAME, DEFAULT_URL, DOMAIN
15 from .helpers
import setup_client
17 _LOGGER = logging.getLogger(__name__)
19 USER_DATA_SCHEMA = vol.Schema(
21 vol.Required(CONF_URL, default=DEFAULT_URL): str,
22 vol.Required(CONF_USERNAME): str,
23 vol.Required(CONF_PASSWORD): str,
24 vol.Optional(CONF_VERIFY_SSL, default=
True): bool,
30 """Config flow for the qBittorrent integration."""
33 self, user_input: dict[str, Any] |
None =
None
34 ) -> ConfigFlowResult:
35 """Handle a user-initiated config flow."""
38 if user_input
is not None:
41 await self.hass.async_add_executor_job(
44 user_input[CONF_USERNAME],
45 user_input[CONF_PASSWORD],
46 user_input[CONF_VERIFY_SSL],
48 except (LoginFailed, Forbidden403Error):
49 errors = {
"base":
"invalid_auth"}
50 except APIConnectionError:
51 errors = {
"base":
"cannot_connect"}
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
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)
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)
vol.Schema add_suggested_values_to_schema(self, vol.Schema data_schema, Mapping[str, Any]|None suggested_values)
_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)