A MagicMirror² module that displays real-time departure times for GVB (Amsterdam public transport) stops, using GTFS static schedule data and GTFS-RT live updates from OVapi.
- Shows the next departures across one or more stops
- Displays scheduled and expected departure times side-by-side when a service is delayed or early
- Color-codes delays (red) and early arrivals (green)
- Automatically re-checks the GTFS static feed daily and reimports only when it has actually changed
- MagicMirror² with Node.js 18 or later
- The module uses
better-sqlite3, which is a native addon. If MagicMirror runs inside Electron you will need to rebuild it for the bundled Electron version (see Rebuilding below).
-
Clone this repository into your MagicMirror
modulesfolder:cd ~/MagicMirror/modules git clone https://github.com/TheAlexLichter/MMM-gvb
-
Install dependencies:
cd MMM-gvb npm install -
If running under Electron, rebuild the native SQLite addon (see Rebuilding).
-
Populate the local GTFS database (required before first run):
node updateGtfs.mjs
This downloads the Dutch national GTFS feed (~150 MB) and imports it into a local SQLite database at
tmp/gtfs.sqlite. It may take a few minutes. You only need to run this manually once. The module will keep the database up to date automatically afterwards. -
Add the module to your
config/config.js(see Configuration).
{
module: "MMM-gvb",
position: "bottom_left",
config: {
stopIds: ["3152445", "3152703"],
updateInterval: 25 * 1000,
gtfsRefreshInterval: 24 * 60 * 60 * 1000,
}
}| Option | Type | Default | Description |
|---|---|---|---|
stopIds |
string[] |
[] |
List of GTFS stop IDs to display departures for. Required, see Finding stop IDs. |
updateInterval |
number |
25000 |
How often (in ms) to refresh departure times from the database and fetch new realtime data. |
gtfsRefreshInterval |
number |
86400000 |
How often (in ms) to check whether the GTFS static feed has changed and reimport if so. Defaults to 24 hours. |
Stop IDs correspond to the stop_id field in the GTFS static data. The easiest way to find them:
-
After running
node updateGtfs.mjs, open the generated SQLite database:sqlite3 tmp/gtfs.sqlite "SELECT stop_id, stop_name FROM stops WHERE stop_name LIKE '%Leidseplein%';" -
Alternatively, browse the raw GTFS feed: download the zip from
http://gtfs.ovapi.nl/openov-nl/gtfs-openov-nl.zipand openstops.txt.
Note that a single physical stop often has multiple stop IDs, one per direction/platform. Add all relevant IDs to stopIds to see departures in both directions.
If MagicMirror uses Electron, the better-sqlite3 native addon must be compiled for the Electron version bundled with MagicMirror. Run:
cd ~/MagicMirror/modules/MMM-gvb
npm run rebuildThis uses @electron/rebuild with the flags already configured in package.json.
Static schedule and realtime data are fetched from OVapi, which provides freely available GTFS and GTFS-RT feeds for Dutch public transport operators including GVB.
MIT