コード例 #1
0
def setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> None:
    """Set up the NMBS sensor with iRail API."""

    api_client = iRail()

    name = config[CONF_NAME]
    show_on_map = config[CONF_SHOW_ON_MAP]
    station_from = config[CONF_STATION_FROM]
    station_to = config[CONF_STATION_TO]
    station_live = config.get(CONF_STATION_LIVE)
    excl_vias = config[CONF_EXCLUDE_VIAS]

    sensors: list[SensorEntity] = [
        NMBSSensor(api_client, name, show_on_map, station_from, station_to, excl_vias)
    ]

    if station_live is not None:
        sensors.append(
            NMBSLiveBoard(api_client, station_live, station_from, station_to)
        )

    add_entities(sensors, True)
コード例 #2
0
ファイル: nmbs.py プロジェクト: yottatsa/home-assistant
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the NMBS sensor with iRail API."""
    from pyrail import iRail
    api_client = iRail()

    name = config[CONF_NAME]
    station_from = config[CONF_STATION_FROM]
    station_to = config[CONF_STATION_TO]
    station_live = config.get(CONF_STATION_LIVE)

    sensors = [NMBSSensor(name, station_from, station_to, api_client)]

    if station_live is not None:
        sensors.append(NMBSLiveBoard(station_live, api_client))

    add_entities(sensors, True)
コード例 #3
0
ファイル: nmbs.py プロジェクト: Martwall/home-assistant
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the NMBS sensor with iRail API."""
    from pyrail import iRail
    api_client = iRail()

    name = config[CONF_NAME]
    station_from = config[CONF_STATION_FROM]
    station_to = config[CONF_STATION_TO]
    station_live = config.get(CONF_STATION_LIVE)

    sensors = [NMBSSensor(name, station_from, station_to, api_client)]

    if station_live is not None:
        sensors.append(NMBSLiveBoard(station_live, api_client))

    add_entities(sensors, True)
コード例 #4
0
ファイル: sensor.py プロジェクト: fbradyirl/home-assistant
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the NMBS sensor with iRail API."""
    from pyrail import iRail
    api_client = iRail()

    name = config[CONF_NAME]
    show_on_map = config[CONF_SHOW_ON_MAP]
    station_from = config[CONF_STATION_FROM]
    station_to = config[CONF_STATION_TO]
    station_live = config.get(CONF_STATION_LIVE)
    excl_vias = config[CONF_EXCLUDE_VIAS]

    sensors = [NMBSSensor(
        api_client, name, show_on_map, station_from, station_to, excl_vias)]

    if station_live is not None:
        sensors.append(NMBSLiveBoard(api_client, station_live))

    add_entities(sensors, True)
コード例 #5
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the NMBS sensor with iRail API."""
    from pyrail import iRail
    api_client = iRail()

    name = config[CONF_NAME]
    show_on_map = config[CONF_SHOW_ON_MAP]
    station_from = config[CONF_STATION_FROM]
    station_to = config[CONF_STATION_TO]
    station_live = config.get(CONF_STATION_LIVE)
    excl_vias = config[CONF_EXCLUDE_VIAS]

    sensors = [NMBSSensor(
        api_client, name, show_on_map, station_from, station_to, excl_vias)]

    if station_live is not None:
        sensors.append(NMBSLiveBoard(api_client, station_live))

    add_entities(sensors, True)
コード例 #6
0
def test_irail_station():

    irail_instance = iRail()
    response = irail_instance.get_stations()
    print(response)