This a module for the MagicMirror. It can display commute time between two given addresses by car, walking, bicycling, or transit. The module uses the Google Maps Directions API to get commute time, which factors in traffic information.
- Navigate into your MagicMirror's
modules
folder and executegit clone /~https://github.com/SamLewis0602/MMM-Traffic.git
. A new folder will appear, navigate into it. - Execute
npm install
to install the node dependencies.
The entry in config.js
can include the following options:
Option | Description |
---|---|
api_key |
The API key, which can be obtained here. Type: string This value is REQUIRED |
origin |
The start location as the address or name of a location. Example: 'Yankee Stadium' or '500 Main Street New York NY' This value is REQUIRED |
destination |
The end location as the address or name of a location. Example: 'PNC Arena' or '1000 Main Street New York NY' This value is REQUIRED |
arrival_time |
If you want the module to give you a departure time, put a 24 hour formatted time that you would like to arrive. Example: '1445' |
mode |
Mode of transportation. Default value: 'driving' Other Options: 'walking' 'bicycling' 'transit' |
route_name |
A nickname for the route that will appear below the route when set. Example: 'Home to school' Default value: None |
show_summary |
Show the route's summary after the nickname. Default value: true but won't show unless route_name is setEffect (in bold): 'Home to school via Route 1/Main St' |
traffic_model |
Model for traffic estimation. Default value: 'best_guess' Other Options: 'optimistic' 'pessimistic' |
changeColor |
When changeColor is set to true, the color of the commute info will change based on traffic. If traffic increases the commute by limitYellow , the symbol and commute text will be yellow. An increase of limitRed will change the color to red. If the traffic doesn't increase the commute by at least limitYellow , the color will be green.Default value: false |
limitYellow |
Percentage increase in commute time due to traffic to turn commute text yellow. Default value: 10 |
limitRed |
Percentage increase in commute time due to traffic to turn commute text red. Default value: 30 |
showGreen |
If you've set changeColor to true but would like the commute text to remain white instead of turn green when there's light/no traffic, set showGreen to false.Default value: true |
interval |
How often the traffic is updated. Default value: 300000 //5 minutes |
loadingText |
The text used when loading the initial commute time. Default value: 'Loading commute...' |
prependText |
The text used in front of the commute time. Default value: 'Current commute is' |
language |
Define the commute time language. Example: en Default value: config.language |
Here is an example of an entry in config.js
{
module: 'MMM-Traffic',
position: 'top_left',
classes: 'dimmed medium', //optional, default is 'bright medium', only applies to commute info not route_name
config: {
api_key: 'your_apikey_here',
mode: 'driving',
origin: '4 Pennsylvania Plaza, New York, NY 10001',
destination: '1 MetLife Stadium Dr, East Rutherford, NJ 07073',
arrival_time: '0800', //optional, but needs to be in 24 hour time if used.
route_name: 'Home to Work',
changeColor: true,
showGreen: false,
limitYellow: 5, //Greater than 5% of journey time due to traffic
limitRed: 20, //Greater than 20% of journey time due to traffic
traffic_model: 'pessimistic',
interval: 120000 //2 minutes
}
},
- request (installed via
npm install
)
- This is my first project using Node, so feel free to submit pull requests or post on the issues/wiki and I will do my best to improve the project.
- Michael Teeuw for creating the awesome MagicMirror2 project that made this module possible.
- Paul-Vincent Roll for creating the Wunderlist module that I used as guidance in creating this module.