1 """Helper functions for swiss_public_transport."""
3 from datetime
import timedelta
4 from types
import MappingProxyType
7 from opendata_transport
import OpendataTransport
23 """In place offset the opendata connector."""
27 now_offset = dt_util.as_local(dt_util.now() + duration)
28 opendata.date = now_offset.date()
29 opendata.time = now_offset.time()
35 """Build a string from a dict duration."""
36 return f
"{d['hours']:02d}:{d['minutes']:02d}:{d['seconds']:02d}"
40 """Build a unique id from a config entry."""
42 f
"{config[CONF_START]} {config[CONF_DESTINATION]}"
44 " via " +
", ".join(config[CONF_VIA])
45 if CONF_VIA
in config
and len(config[CONF_VIA]) > 0
50 if config.get(CONF_TIME_STATION, DEFAULT_TIME_STATION) ==
"arrival"
53 + (
" at " + config[CONF_TIME_FIXED]
if CONF_TIME_FIXED
in config
else "")
56 if CONF_TIME_OFFSET
in config
None offset_opendata(OpendataTransport opendata, dict[str, int] offset)
str dict_duration_to_str_duration(dict[str, int] d)
str unique_id_from_config(MappingProxyType[str, Any]|dict[str, Any] config)