1 """Adds config flow for SabNzbd."""
3 from __future__
import annotations
8 import voluptuous
as vol
24 from .const
import DOMAIN
25 from .helpers
import get_client
27 _LOGGER = logging.getLogger(__name__)
29 USER_SCHEMA = vol.Schema(
33 type=TextSelectorType.URL,
38 type=TextSelectorType.PASSWORD,
46 """Sabnzbd config flow."""
51 self, user_input: dict[str, Any] |
None =
None
52 ) -> ConfigFlowResult:
53 """Handle reconfiguration flow."""
57 self, user_input: dict[str, Any] |
None =
None
58 ) -> ConfigFlowResult:
59 """Handle a flow initialized by the user."""
62 if user_input
is not None:
63 sab_api = await
get_client(self.hass, user_input)
65 errors[
"base"] =
"cannot_connect"
69 CONF_URL: user_input[CONF_URL],
70 CONF_API_KEY: user_input[CONF_API_KEY],
79 parsed_url = yarl.URL(user_input[CONF_URL])
81 title=
slugify(parsed_url.host), data=user_input
ConfigFlowResult async_step_reconfigure(self, dict[str, Any]|None user_input=None)
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)
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)
ConfigEntry _get_reconfigure_entry(self)
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)
def get_client(HomeAssistant hass, data)