A Home Assistant custom integration for Belgian trains (SNCB/NMBS) with feature parity to the core Home Assistant NMBS integration.
This integration provides real-time train information from the iRail API (https://api.irail.be/):
-
Connection Sensors: Monitor travel time between two stations, including:
- Real-time departure and arrival information
- Platform information for both departure and arrival
- Delay information in minutes
- Via connections with transfer details
- Cancellation status
- Vehicle ID
- Optional map display with station coordinates
-
Liveboard Sensors: View the next departures from any station:
- Legacy connection-based liveboards: For existing connections created before the subentry update, liveboard sensors for departure and arrival stations are automatically created (disabled by default for backward compatibility)
- Standalone liveboards: Add liveboard sensors for any station independently via the "Add Entry" button (requires Home Assistant 2025.2+)
- Next train departure time
- Destination station
- Platform information
- Delay information
- Vehicle ID
- Extra train indicator
- Open HACS in Home Assistant
- Go to "Integrations"
- Click the three dots in the top right corner
- Select "Custom repositories"
- Add this repository URL
- Select "Integration" as the category
- Click "Add"
- Search for "SNCB/NMBS" and install
- Copy the
custom_components/belgiantraindirectory to your Home Assistantcustom_componentsdirectory - Restart Home Assistant
- Go to Settings → Devices & Services
- Click "+ Add Integration"
- Search for "SNCB/NMBS"
- Select your departure station from the dropdown
- Select your arrival station from the dropdown
- (Optional) Enable "Exclude via connections" to only show direct trains
- (Optional) Enable "Show on map" to display station coordinates in sensor attributes
With Home Assistant 2025.2+, the setup uses a guided flow:
-
Choose Sensor Type: After API verification, you'll see a menu:
- "Monitor travel time between stations" (Connection)
- "Monitor departures from a station" (Liveboard)
-
If you choose Connection:
- Select departure and arrival stations
- Choose options (exclude via connections, show on map)
- Optional: Check boxes to also add liveboard sensors for the departure and/or arrival stations
- The connection sensor (and any selected liveboards) will be created
-
If you choose Liveboard:
- Select the station to monitor
- The liveboard sensor will be created
The integration will create:
- Connection sensor(s) showing travel time in minutes between stations
- Liveboard sensor(s) showing next departures from selected stations (if you checked the boxes or chose a liveboard)
After initial setup, you can add more connections or liveboards:
- Go to Settings → Devices & Services
- Find your SNCB/NMBS integration
- Click "Add Entry" (subentry button)
- Choose "Connection" or "Liveboard"
- Configure the sensor
- Click "Submit"
This allows you to add as many connections or liveboards as needed.
For existing connections created before Home Assistant 2025.2:
- Connection sensor shows travel time (enabled by default)
- Liveboard sensors for departure and arrival stations are automatically created (disabled by default for backward compatibility)
- To monitor departures, enable these liveboard sensors in Home Assistant
Shows the total travel time in minutes between departure and arrival stations.
Attributes:
destination: Destination station namedirection: Direction nameplatform_departing: Departure platformplatform_arriving: Arrival platformvehicle_id: Train vehicle IDdeparture: Human-readable departure time ("In X minutes")departure_minutes: Departure time in minutesdelay: Delay information ("X minutes")delay_minutes: Delay in minutescanceled: Boolean indicating if train is canceledvia: Via station name (if applicable)via_arrival_platform: Via station arrival platform (if applicable)via_transfer_platform: Via station departure platform (if applicable)via_transfer_time: Transfer time at via station in minutes (if applicable)latitude: Station latitude (if "Show on map" enabled)longitude: Station longitude (if "Show on map" enabled)
Shows the next departure from a station.
Attributes:
departure: Human-readable departure time ("In X minutes")departure_minutes: Departure time in minutesextra_train: Boolean indicating if this is an extra trainvehicle_id: Train vehicle IDmonitored_station: The station being monitoreddelay: Delay information (if applicable)delay_minutes: Delay in minutes (if applicable)
This integration provides service actions to retrieve real-time information from the Belgian rail network.
Retrieve information about current disturbances on the Belgian rail network.
Parameters:
line_break_character(optional): Custom character to use for line breaks in disturbance descriptions
Example:
service: belgiantrain.get_disturbances
data:
line_break_character: "<br>"
response_variable: disturbancesResponse: Returns a list of current disturbances with:
id: Disturbance IDtitle: Short descriptiondescription: Detailed descriptiontype: Type of disturbancetimestamp: When the disturbance was reported
Retrieve detailed information about a specific train vehicle.
Parameters:
vehicle_id(required): Unique identifier of the train vehicle (e.g., "BE.NMBS.IC1832")date(optional): Specific date for vehicle information in DDMMYY format (day, month, 2-digit year). For example, "111224" represents December 11, 2024. Defaults to current date if not specified.alerts(optional): Include service alerts for the vehicle (default: false)
Example:
service: belgiantrain.get_vehicle
data:
vehicle_id: "BE.NMBS.IC1832"
alerts: true
response_variable: vehicle_infoResponse: Returns vehicle information with:
vehicle_id: Train vehicle IDname: Train namestops: List of stops with station, platform, time, delay, and cancellation status
Retrieve composition details of a specific train (carriages, facilities, train length).
Parameters:
train_id(required): Unique identifier of the train (e.g., "S51507" or "IC1832")
Example:
service: belgiantrain.get_composition
data:
train_id: "S51507"
response_variable: compositionResponse: Returns train composition with:
train_id: Train identifiersegments: List of train segments with:origin: Segment origin stationdestination: Segment destination stationunits: List of carriages with material type, toilet availability, bike section, and accessibility information
Use case: Plan which carriage to board based on facilities (first class, bike storage, accessibility).
Retrieve list of all Belgian railway stations with their IDs and locations.
Parameters:
name_filter(optional): Filter stations by name (case-insensitive partial match)
Example:
service: belgiantrain.get_stations
data:
name_filter: "Brussels"
response_variable: stationsResponse: Returns:
stations: List of stations with ID, name, standard name, latitude, and longitudecount: Number of stations returned
Use case: Find station IDs for configuration or discover nearby stations.
Note: For forcing entity updates, use the built-in Home Assistant service homeassistant.update_entity instead of a custom refresh service.
This repository contains multiple files for development:
| File | Purpose |
|---|---|
custom_components/belgiantrain/ |
Integration source code |
tests/belgiantrain/ |
Integration tests |
scripts/ |
Development scripts (setup, lint, develop) |
requirements.txt |
Python packages for development/testing |
- Clone the repository
- Run
scripts/setupto install dependencies - Run
scripts/lintto check code quality - Run
scripts/developto start Home Assistant for testing
pytest tests/belgiantrain/This integration uses the iRail API (https://api.irail.be/) which provides real-time Belgian train information from SNCB/NMBS.
This integration achieves feature parity with the core Home Assistant NMBS integration.
Contributions are welcome! Please read CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.