Nederlandse Spoorwegen (NS)
The Nederlandse Spoorwegen (NS) integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides real-time information about Dutch train schedules using the NS API
Prerequisites
To use this integration, you need an API key from the NS API Portal.
Obtaining an API Key
- Create an account on the NS API Portal
. - Request an API key for the
Reisinformatie
API, which is part of theNs-App
product.
Configuration
To add the Nederlandse Spoorwegen (NS) service to your Home Assistant instance, use this My button:
Manual configuration steps
If the above My button doesn’t work, you can also perform the following steps manually:
-
Browse to your Home Assistant instance.
-
In the bottom right corner, select the
Add Integration button. -
From the list, select Nederlandse Spoorwegen (NS).
-
Follow the instructions on screen to complete the setup.
Managing routes
After adding the integration, you can manage your travel routes:
- Go to Settings > Devices & services.
- Find the Nederlandse Spoorwegen integration.
- Click Configure.
- Add or remove routes as needed.
The integration provides a station selector in the UI, so you don’t need to manually look up station codes. Simply search for and select your departure and arrival stations from the dropdown menus during route configuration.
Searching for a specific train vs. the next train
The default behavior (without specifying a time) gives you information about the next train that fits the criteria (from, to, via stations).
When you specify a departure time during route configuration, 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. For example, when you normally take the 08:06 train and want to get information about this specific train, but there is another train departing just minutes before your train, your time window to warn you about a delay might be too small.
Using a specific 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 API usage limits.
Data source
The data is provided by Nederlandse Spoorwegen through their official API, ensuring high-quality and up-to-date information about train schedules, delays, and service disruptions.
Troubleshooting
Authentication errors
If you encounter authentication errors:
- Verify your API key is correct.
- Ensure your NS API subscription is active.
- Check that you’re using the correct API (Reisinformatie API).
Removing the integration
This integration follows standard integration removal.
To remove an integration instance from Home Assistant
- Go to Settings > Devices & services and select the integration card.
- From the list of devices, select the integration instance you want to remove.
- Next to the entry, select the three dots
menu. Then, select Delete.
All entities and data associated with the integration will be removed.