Git Product home page Git Product logo

mmm-stib2's Introduction

MMM-stib2

This is a module for the MagicMirror².

This module shows waiting times for STIB transport (Brussels). It is a re-write of https://github.com/danito/MMM-stib which didn't really fit the bill for me.

This module will group stops and will only show a single bus (or tram, metro) route once. I.e. the same line will not show in multiple stops. This reduces noise if you want to configure the module to show multiple stops that belong to the same line (but have overall different sets of lines.)

Example screenshot

The module also queries the STIB messages API for disruptions and shows such disruptions. It also shows icons when the actual waiting time is unknown (only theoretical time is available), the vehicle is blocked or the vehicle is the last of the day (end of service).

It relies on the STIB OpenData API: https://opendata.stib-mivb.be . It requires an access token that can be obtained for free.

I wrote this module for my own usage, and it comes with no guarantee. However, I'm not opposed to fixing (small) issues or merging pull requests.

Known issue

There seems to be a problem with the STIB server related to HTTP2 which prevent CORS pre-flight requests from succeding when HTTP2 is used. When using chromium, use the --disable-http2 flag to workaround the problem.

If the issue persists, we could make the requests in the node helper to bypass CORS.

Using the module

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

var config = {
    modules: [
      {
        module: "MMM-stib2",
        position: "bottom_right",
        config: {
          apiToken: "STIB OPEN DATA API TOKEN",
          stops: [{
            name: "Delta",
            id: ["3546", "3520"]
          }, {
            name: "Flagey",
            id: ["1280", "1354", "3508", "3572"]
          }]
        }
      }
    ]
}

See below for details.

Configuration options

Option Description
apiToken Required STIB open data API token. See below for instructions on getting such a token.
stops Required Array of stop objects. A stop object has a freetext name and an ìd property. id is an array of ids for bus stops. These id can be found in the stops.txt file from the STIB GTFS dataset.

STIB OpenData

To create a STIB OpenData token, go to https://opendata.stib-mivb.be/ and create an account. In "My Space", click on "Operation Monitoring", then "Subscribe". Then, go to "Subscriptions" and generate keys. The token you should use in the configuration of this module is the "Access Token". Use -1 to specify an API token that never expires.

Ideas / TODO list

  • Scroll vertically if too many lines need to be shown (?)
  • Internationalize. Messages are currently hardcoded to French.

mmm-stib2's People

Contributors

bendardenne avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

novalore

mmm-stib2's Issues

Showing "no data"

Hello @bendardenne ,

This is my config:

{
module: "MMM-stib2", // Transport de Bruxelles
position: "bottom_left",
config: {
apiToken: "xxxxxxxx",
stops: [
{
name: "EDDY MERCKX",
id: ["8651"]
},
]
}
},

I tried multiples stations ID and name. I refreshed the access token. Nothing changes. I've got the "no data" sentence on my mirror.
Furthermore, I checked the console, there is no problem.

Any issue to solve this problem ?
Thanks !
Have a wonderful week end,

  • Max

What if the same bus line stops at two stops in the array for different destinations?

The module is designed to avoid duplicates
for (let line in stop) { // Don't show the same line on multiple stops if (seen.has(line)) { continue; }

But this is not always a good design choice.
around Place Jourdan, for example, bus line 80 stops at Jourdan heading to Porte de Namur and at Etangs heading to Haren.
It would be great if the module could display the same line at two different stops in this case.
Ideally we would have a config option to enable or disable this feature.
Something like:
allowMultipleStopsSameLine: "yes"

No data (with valid API key)

Hi,
Does someone still use this module? It looks great in the screenshot and it would be ideal for my mirror, but I can't get anything from the API and there are no logs. I have the impression that the endpoints changed. Check https://data.stib-mivb.be/explore/dataset/waiting-time-rt-production/api/ for example.

In case anyone will answer, the following is my configuration entry for the module:
{ module: "MMM-stib2", position: "bottom_center", header: "STIB-MIVB", config: { apiToken: "XXX", //here I added my Api key from https://stibmivb.opendatasoft.com/account/api-keys/ stops: [{ name: "Jourdan", id: ["3921", "3922", "3158B"] }, { name: "Etangs", id: ["1777B", "1733", "3160", "3572"] }] } },

GTFS ???

Bonsoir merci pour le module , il est top.
par contre les gtfs je ne trouve pas , la liste des arrêts avec les noms et id si vous pouvez m aider pour ca, merci aussi savez vous quel est le temps max que le système accès pour la clé ou si on peut mettre une valeur pour ne pas devoir régénérer. Bonne soiree

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.