Skip to content

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

License

Notifications You must be signed in to change notification settings

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

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.

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-CTA',
      config: {
        // See below for configurable options
      }
    }
  ]
}

Configuration options

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
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'
    }
  ]
}
Property Description
type Type of stop. Either bus or train
id Stop ID. See Finding Stop IDs
name Name of stop. This is displayed in the header of the stop's results.

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.

Development

Installation

Install dev dependencies

npm install

Testing

There is a test suite using Jest.

npm test

Linting

# Run linting
npm run lint

# Fix linting errors
npm 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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published