This is a module for the MagicMirror².
This module displays Chicago Transit Authority (CTA) bus and train arrival times.
In ~/MagicMirror/modules
git clone https://github.com/JHWelch/MMM-CTANo dependencies are required for usage. See below for development dependencies.
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.
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 |
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. |
- Go to CTA Trackers and select Train or Bus Tracker.
- Search for your stop inside of the given app
- Once you find your stop, obtain the Id. It will be the number at the end of the page's URL
- For train tracker, it may look like
?sid={id}. Theidis the stop ID. - For bus tracker, it may look like
Southbound/{id}. Theidis the stop ID.
- For train tracker, it may look like
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' },In ~/MagicMirror/modules/MMM-CTA
git pullThere are no additional dependencies to update.
Install dev dependencies
npm installThere is a test suite using Jest.
node --run test# Run linting
node --run lint
# Fix linting errors
node --run fixThis module is inspired by MMM-CTA from NateDee.
