Skip to content

TheAlexLichter/MMM-gvb

Repository files navigation

MMM-gvb

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.

Features

  • 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

Prerequisites

  • 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).

Installation

  1. Clone this repository into your MagicMirror modules folder:

    cd ~/MagicMirror/modules
    git clone https://github.com/TheAlexLichter/MMM-gvb
  2. Install dependencies:

    cd MMM-gvb
    npm install
  3. If running under Electron, rebuild the native SQLite addon (see Rebuilding).

  4. 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.

  5. Add the module to your config/config.js (see Configuration).

Configuration

{
  module: "MMM-gvb",
  position: "bottom_left",
  config: {
    stopIds: ["3152445", "3152703"],
    updateInterval: 25 * 1000,
    gtfsRefreshInterval: 24 * 60 * 60 * 1000,
  }
}

Options

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.

Finding stop IDs

Stop IDs correspond to the stop_id field in the GTFS static data. The easiest way to find them:

  1. 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%';"
  2. Alternatively, browse the raw GTFS feed: download the zip from http://gtfs.ovapi.nl/openov-nl/gtfs-openov-nl.zip and open stops.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.

Rebuilding

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 rebuild

This uses @electron/rebuild with the flags already configured in package.json.

GTFS data source

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.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors