1 """Config flow for israel rail."""
6 from israelrailapi
import TrainSchedule
7 from israelrailapi.stations
import STATIONS
8 import voluptuous
as vol
12 from .const
import CONF_DESTINATION, CONF_START, DOMAIN
14 STATIONS_NAMES = [station[
"Heb"]
for station
in STATIONS.values()]
17 DATA_SCHEMA = vol.Schema(
19 vol.Required(CONF_START): vol.In(STATIONS_NAMES),
20 vol.Required(CONF_DESTINATION): vol.In(STATIONS_NAMES),
24 _LOGGER = logging.getLogger(__name__)
28 """Israel rail config flow."""
33 self, user_input: dict[str, Any] |
None =
None
34 ) -> ConfigFlowResult:
35 """Async user step to set up the connection."""
38 train_schedule = TrainSchedule()
40 await self.hass.async_add_executor_job(
42 user_input[CONF_START],
43 user_input[CONF_DESTINATION],
46 _LOGGER.exception(
"Unknown error")
47 errors[
"base"] =
"unknown"
49 unique_id = f
"{user_input[CONF_START]} {user_input[CONF_DESTINATION]}"
60 data_schema=DATA_SCHEMA,
ConfigFlowResult async_step_user(self, dict[str, Any]|None user_input=None)
None _abort_if_unique_id_configured(self, dict[str, Any]|None updates=None, bool reload_on_update=True, *str error="already_configured")
ConfigEntry|None async_set_unique_id(self, str|None unique_id=None, *bool raise_on_progress=True)
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)