1 """The Israel Rail component."""
5 from israelrailapi
import TrainSchedule
12 from .const
import CONF_DESTINATION, CONF_START, DOMAIN
13 from .coordinator
import IsraelRailDataUpdateCoordinator
15 _LOGGER = logging.getLogger(__name__)
18 PLATFORMS: list[Platform] = [Platform.SENSOR]
21 type IsraelRailConfigEntry = ConfigEntry[IsraelRailDataUpdateCoordinator]
25 """Set up Israel rail from a config entry."""
28 start = config[CONF_START]
29 destination = config[CONF_DESTINATION]
31 train_schedule = TrainSchedule()
34 await hass.async_add_executor_job(train_schedule.query, start, destination)
35 except Exception
as e:
37 translation_domain=DOMAIN,
38 translation_key=
"request_timeout",
39 translation_placeholders={
40 "config_title": entry.title,
46 hass, train_schedule, start, destination
48 await israel_rail_coordinator.async_config_entry_first_refresh()
49 entry.runtime_data = israel_rail_coordinator
51 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
57 """Unload a config entry."""
58 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, IsraelRailConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, IsraelRailConfigEntry entry)