mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
* Add typing/async to NMBS * Fix tests * Boolean fields * Update homeassistant/components/nmbs/sensor.py Co-authored-by: Jorim Tielemans <tielemans.jorim@gmail.com> --------- Co-authored-by: Shay Levy <levyshay1@gmail.com> Co-authored-by: Jorim Tielemans <tielemans.jorim@gmail.com>
33 lines
832 B
Python
33 lines
832 B
Python
"""The NMBS integration."""
|
|
|
|
from typing import Final
|
|
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
DOMAIN: Final = "nmbs"
|
|
|
|
PLATFORMS: Final = [Platform.SENSOR]
|
|
|
|
CONF_STATION_FROM = "station_from"
|
|
CONF_STATION_TO = "station_to"
|
|
CONF_STATION_LIVE = "station_live"
|
|
CONF_EXCLUDE_VIAS = "exclude_vias"
|
|
CONF_SHOW_ON_MAP = "show_on_map"
|
|
|
|
|
|
def find_station_by_name(hass: HomeAssistant, station_name: str):
|
|
"""Find given station_name in the station list."""
|
|
return next(
|
|
(s for s in hass.data[DOMAIN] if station_name in (s.standard_name, s.name)),
|
|
None,
|
|
)
|
|
|
|
|
|
def find_station(hass: HomeAssistant, station_name: str):
|
|
"""Find given station_id in the station list."""
|
|
return next(
|
|
(s for s in hass.data[DOMAIN] if station_name in s.id),
|
|
None,
|
|
)
|