Nederlandse Spoorwegen (NS)

This integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] will provide you with time table information of the Nederlandse Spoorwegen train service in the Netherlands.

To obtain an API key, create an account on the NS API-Portaal and obtain an API key for the Reisinformatie API which is part of the Ns-App product.

The nederlandse_spoorwegen integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] can be configured using your configuration.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file. 在更改了configuration.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] 文件后,重启 Home Assistant 以应用更改。 该集成现在显示在集成页面的 设置 > 设备与服务 下。其实体在集成卡片上以及实体标签上列出。

# Example configuration.yaml entry
sensor:
- platform: nederlandse_spoorwegen
  api_key: NS_API_KEY
  routes:
    - name: Rotterdam-Amsterdam
      from: Rtd
      to: Asd
    - name: Groningen-Zwolle-Maastricht
      from: Gn
      to: Mt
      via: Zl
    - name: "AlmereBuiten-Duivendrecht-the-08h06m-train"
      from: Almb
      to: Dvd
      time: "08:06:00"

Configuration Variables

api_key string Required

The API key provided by the Nederlandse Spoorwegen.

routes list (Optional)

List of travel routes.

name string Required

Name of the route.

from string Required

The departure station.

to string Required

The arrival station.

via string (Optional)

A station the route needs to pass through.

time time (Optional)

Optional time to search for a specific train.

Station codes

Station codes must be used and can be looked up here.

Searching a specific train vs. the next train

The default behavior (without configuration variable time) gives you the information about the next train that fits the criteria (from, to, via). When using the configuration variable time, you can search for a specific train. This is convenient when searching for the next train doesn’t give you enough time to base an automation on. E.g., when you normally take the 08h06m train and want to get information about this train, but there is another train that’s departing just minutes before your train, your time window to warn you on a delay might be too small.

Using time only updates the route sensor during a time window around the chosen time. Outside this window, the route sensor’s state is unknown. The window is from half an hour before the chosen time until half an hour after the chosen time. In this way, you can have multiple routes with specific trains before hitting the FUP threshold for using NS API.

The data are coming from Nederlandse Spoorwegen.