Skip to content

JHWelch/MMM-CTA

Repository files navigation

MMM-CTA

This is a module for the MagicMirror².

This module displays Chicago Transit Authority (CTA) bus and train arrival times.

Screenshot

Installation

In ~/MagicMirror/modules

git clone https://github.com/JHWelch/MMM-CTA

No dependencies are required for usage. See below for development dependencies.

Obtaining CTA API keys

You need to obtain API keys to access CTA data. The API keys are two separate keys for two services.

The bus tracker API key can be obtained immediately, the train tracker key can take a few days to register.

Configuration

To use this module, add the following configuration to your config/config.js file.

{
  module: 'MMM-CTA',
  config: {
    busApiKey: 'YOUR_BUS_API_KEY',
    trainApiKey: 'YOUR_TRAIN_API_KEY',
    stops: [
      // See `stops` option below
    ],
  }
}
Option Required? Description
busApiKey Required See Obtaining CTA API keys
trainApiKey Required See Obtaining CTA API keys
stops Required Array of stops to display. See stops option
updateInterval Optional Refresh time in milliseconds
Default 60000 milliseconds (1 minute)
maxResultsBus Optional Maximum number of bus results to display
Default 5
maxResultsTrain Optional Maximum number of train results to display
Default 5
routeIcons Optional True/False - Display icons next to routes.
Default true
showHeaders Optional True/False - Display headers for each stop.
Default true
showRoute Optional True/False - Display route name for bus.
Default 'false'
suffixStyle Optional Style of suffix for the arrival time. long, short, or none
Default long

stops option

The stops option is an array of objects. Each object represents a stop to display.

{
  stops: [
    {
      type: 'bus',
      id: 561,
      name: 'Chicago and Milwaukee'
    },
    {
      type: 'train',
      id: 41410,
      name: 'Blue Line',
      minimumArrivalTime: 600000,
    }
  ]
}
Property Required? Description
type Required Type of stop. Either bus or train
id Required Stop ID. See Finding Stop IDs
name Optional Name of stop. This is displayed in the header of the stop's results.
minimumArrivalTime Optional The minimum time to arrival for the bus or train to be displayed. In ms. Default 0.
showHeaders Optional Override global showHeaders option for this stop only.
Default: global value.
showRoute Optional Override global showRoute option for this stop only.
Default: global value.

Finding Stop IDs

  1. Go to CTA Trackers and select Train or Bus Tracker.
  2. Search for your stop inside of the given app
  3. Once you find your stop, obtain the Id. It will be the number at the end of the page's URL
    1. For train tracker, it may look like ?sid={id}. The id is the stop ID.
    2. For bus tracker, it may look like Southbound/{id}. The id is the stop ID.

Update

Automatic Update

Did you know MagicMirror² has a built-in module updater? Read more about it here.

Add the following to your updates array of updatenotification in config/config.js

{ 'MMM-CTA': 'git pull' },

Manual Update

In ~/MagicMirror/modules/MMM-CTA

git pull

There are no additional dependencies to update.

Development

Installation

Install dev dependencies

npm install

Testing

There is a test suite using Jest.

node --run test

Linting

# Run linting
node --run lint

# Fix linting errors
node --run fix

Thanks

This module is inspired by MMM-CTA from NateDee.

About

MagicMirror² module for displaying Train & Bus arrival times for the CTA

Topics

Resources

Contributing

Stars

Watchers

Forks

Used by

Contributors

Languages