1 """Config flow for Downloader integration."""
3 from __future__
import annotations
8 import voluptuous
as vol
10 from homeassistant
import exceptions
14 from .const
import _LOGGER, CONF_DOWNLOAD_DIR, DEFAULT_NAME, DOMAIN
18 """Handle a config flow for Downloader."""
23 self, user_input: dict[str, Any] |
None =
None
24 ) -> ConfigFlowResult:
25 """Handle the initial step."""
26 errors: dict[str, str] = {}
28 if user_input
is not None:
31 except DirectoryDoesNotExist:
32 errors[
"base"] =
"directory_does_not_exist"
38 data_schema=vol.Schema(
40 vol.Required(CONF_DOWNLOAD_DIR): cv.string,
47 """Validate the user input if the directory exists."""
48 download_path = user_input[CONF_DOWNLOAD_DIR]
49 if not os.path.isabs(download_path):
50 download_path = self.hass.config.path(download_path)
52 if not await self.hass.async_add_executor_job(os.path.isdir, download_path):
54 "Download path %s does not exist. File Downloader not active",
57 raise DirectoryDoesNotExist
61 """Error to indicate the specified download directory does not exist."""
None _validate_input(self, dict[str, Any] user_input)
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_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)