Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme #2

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());