1 """Config flow for Local file."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
6 from typing
import Any, cast
8 import voluptuous
as vol
12 SchemaCommonFlowHandler,
13 SchemaConfigFlowHandler,
19 from .const
import DEFAULT_NAME, DOMAIN
20 from .util
import check_file_path_access
24 handler: SchemaCommonFlowHandler, user_input: dict[str, Any]
26 """Validate options selected."""
27 file_path: str = user_input[CONF_FILE_PATH]
28 if not await handler.parent_handler.hass.async_add_executor_job(
29 check_file_path_access, file_path
33 handler.parent_handler._async_abort_entries_match(
34 {CONF_FILE_PATH: user_input[CONF_FILE_PATH]}
40 DATA_SCHEMA_OPTIONS = vol.Schema(
45 DATA_SCHEMA_SETUP = vol.Schema(
47 vol.Optional(CONF_NAME, default=DEFAULT_NAME):
TextSelector(),
49 ).extend(DATA_SCHEMA_OPTIONS.schema)
53 schema=DATA_SCHEMA_SETUP,
54 validate_user_input=validate_options,
57 schema=DATA_SCHEMA_SETUP,
58 validate_user_input=validate_options,
64 validate_user_input=validate_options,
70 """Handle a config flow for Local file."""
72 config_flow = CONFIG_FLOW
73 options_flow = OPTIONS_FLOW
76 """Return config entry title."""
77 return cast(str, options[CONF_NAME])
str async_config_entry_title(self, Mapping[str, Any] options)
dict[str, Any] validate_options(SchemaCommonFlowHandler handler, dict[str, Any] user_input)