Skip to content

Commit

Permalink
Merge pull request #2 from JHWelch/update-readme
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
JHWelch authored Jan 21, 2024
2 parents 29feb61 + 8339d46 commit 4008a24
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 35 deletions.
2 changes: 1 addition & 1 deletion MMM-CTA.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Module.register('MMM-CTA', {
updateInterval: 60000,
trainApiKey: null,
busApiKey: null,
maxResultsTrain: 5,
maxResultsBus: 5,
maxResultsTrain: 5,
stops: [],
},

Expand Down
81 changes: 65 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This is a module for the [MagicMirror²](https://github.com/MichMich/MagicMirror/).

<!-- TODO: Add API Key instructions -->

## Installation

In ~/MagicMirror/modules
Expand All @@ -17,30 +15,76 @@ cd MMM-CTA
npm install --production
```

## Obtaining CTA API keys

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

- [Bus API](http://www.transitchicago.com/developers/bustracker.aspx)
- [Train API](http://www.transitchicago.com/developers/traintrackerapply.aspx)

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:
```js
var config = {
modules: [
{
module: 'MMM-CTA',
config: {
// See below for configurable options
}
}
]
modules: [
{
module: 'MMM-CTA',
config: {
// See below for configurable options
}
}
]
}
```

## Configuration options
<!-- TODO: Add config options -->

| Option | Required? | Description |
| ---------------- | ------------ | ---------------------------------------------------------------------- |
| `busToken` | **Required** | How to get? |
| `trainToken` | **Required** | How to get? |
| `updateInterval` | *Optional* | Refresh time in milliseconds <br>Default 60000 milliseconds (1 minute) |
| Option | Required? | Description |
| ----------------- | ------------ | ---------------------------------------------------------------------- |
| `busApiKey` | **Required** | How to get? |
| `trainApiKey` | **Required** | How to get? |
| `stops` | **Required** | Array of stops to display. See [`stops` option](#stops-option) |
| `updateInterval` | *Optional* | Refresh time in milliseconds <br>Default 60000 milliseconds (1 minute) |
| `maxResultsBus` | *Optional* | Maximum number of bus results to display <br>Default 5 |
| `maxResultsTrain` | *Optional* | Maximum number of train results to display <br>Default 5 |

### `stops` option

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

```js
{
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](#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](https://www.transitchicago.com/tracker/) 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

Expand All @@ -67,3 +111,8 @@ npm run lint
# Fix linting errors
npm run fix
```


## Thanks

This module is inspired by [MMM-CTA from NateDee](https://github.com/NateDee/MMM-CTA).
15 changes: 0 additions & 15 deletions __mocks__/mockResponse.js

This file was deleted.

4 changes: 1 addition & 3 deletions __mocks__/node-fetch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
mockResponse = require('mockResponse');

jest.mock('node-fetch', () => jest.fn(() => Promise.resolve(mockResponse())));
jest.mock('node-fetch', () => jest.fn());

0 comments on commit 4008a24

Please sign in to comment.