Code Monkey home page Code Monkey logo

mmm-nstreinen's Introduction

NS Trains - MagicMirror² module

Build Status

This is a module for MagicMirror². Shows informantion on trains departuring a configurable Dutch trainstation.

(old images, will be replaced for V2) Example Visualization Example Visualization with destination

Installing the module

To install the module, just clone this repository to your modules folder:

  • git clone https://github.com/qistoph/MMM-nstreinen.git nstreinen
  • cd nstreinen
  • npm install to install the dependencies

Updating the module

Two simple steps, in the module dir:

  • git pull
  • npm install to update the dependencies

Using the module

You will need an apikey for the NS-API. This can be requested at http://www.ns.nl/reisinformatie/ns-api.

To use this module, add it to the modules array in the config/config.js file:

modules: [
  {
    module: 'nstreinen',
    position: 'top_right',
    header: 'Treinen vanaf Schiphol Airport',
    config: {
      apiKey:'<NS-API-Key>',
      fromStation: 'SHL'
    }
  }
]

Configuration options

The following properties can be configured:

Option Description
apiKey Your API key.
Request your credentials at NS API
Required
fromStation The station code to show trains for.
Required
toStation The destination (station code) to show trains for. If this is configured the trains and required transfers from station to this destination will be shown.
Optional
maxEntries Maximum number of trains to show per station.
Default value: 5
reloadInterval Number of milliseconds between refresh.
Keep in mind there is a maximum of 50.000 requests per day for the API.
Default value: 5 * 60 * 1000 (5 minutes)
departureOffset Trip planning only, requires destination: Number of seconds to 'delay' the trip plan with.
Especially usefull when you need time to travel to the train station.
Default value: 0 (0 seconds)
displaySymbol Defines wether or not to show a symbol for each line.
Possible values: true or false.
Default value: true
symbolMapping Maps the train types to the symbol to show.
If the train type is not found, the symbol for default is used.
Possible symbols: See Font Awesome website.
Default value: See Default symbolMapping.
fade Fade the trains listed to black. (Gradient)
Possible values: true or false
Default value: true
fadePoint Where to start fade?
Possible values: 0 (top of the list) - 1 (bottom of list)
Default value: 0.25

Station codes

NS API uses station codes to identify stations. You cannot (unlike version 1) use station names. After configuring the nstreinen module with an apiKey in your config.js you can use stations.js:

$ node modules/nstreinen/stations.js | grep -i 'schip'
SHL - Schiphol Airport

Default symbolMapping

symbolMapping: {
  'IC': 'train',
  'SPR': 'stop-circle',
  'Intercity': 'train',
  'Intercity direct': 'forward',
  'Sprinter': 'stop-circle',
  'Stopbus i.p.v. trein': 'bus',
  'Snelbus i.p.v. trein': 'bus',
  'default': 'train'
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.