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 execute these commands:
git clone https://github.com/SamLewis0602/MMM-Traffic.git
cd MMM-Traffic
npm install
- request (installed via
npm install
)
This module has a LOT of customization, don't let that intimidate you! All that's required to get up and running are these three config options:
Option | Description | Type |
---|---|---|
api_key |
The API key, which can be obtained here. | string |
origin |
The name or address of the starting location. | string |
destination |
The name or address of the destination location. | string |
Option | Description | Type | Default Value | Supported Options |
---|---|---|---|---|
language |
Define the commute time language. | string | config.language |
Any language string |
mode |
Mode of transportation. | string | 'driving' |
'driving' 'walking' 'bicycling' 'transit' |
avoid |
Avoid certain types of transportation on the route. | string | '' |
'tolls' 'highways' 'ferries' |
traffic_model |
Model for traffic estimation. | string | 'best_guess' |
'best_guess' 'optimistic' 'pessimistic' |
interval |
How often the traffic is updated in milliseconds. | integer | 300000 (5 minutes) |
Use these config options to translate the module's various text to your language.
Option | Description | Type | Default Value |
---|---|---|---|
loadingText |
The text used when loading the initial commute time. | string | 'Loading commute...' |
prependText |
The text used in front of the commute time. | string | 'Current commute is' |
Option | Description | Type | Example |
---|---|---|---|
waypoints |
A pipe separated list of locations that you want your route to pass through. | string | 'Disneyworld|Universal Studios' |
Option | Description | Type | Default Value | Supported Options |
---|---|---|---|---|
showRouteInfo |
Set to true to show info about your route below the commute time. | boolean | false |
true false |
showRouteInfoText |
Text displayed when showRouteInfo is true . Supports token replacement. |
string | '{routeName} via {summary}' |
Supported tokens: {routeName} {summary} {arrivalTime} {origin} {destination} {detailedSummary} {summary} not supported when mode == 'transit' |
route_name |
A nickname for the route used in combination with showRouteInfoText |
string | None | any string i.e. 'Home to Work' |
Use this option to show what time you need to leave to arrive on time, rather than the duration.
Option | Description | Type | Example |
---|---|---|---|
arrival_time |
24 hour formatted arrival time with no separator | string | '0930' |
Option | Description | Type |
---|---|---|
mon_destination tues_destination wed_destination thurs_destination fri_destination sat_destination sun_destination |
Used to specify a different destination for particular days of the week. | string |
mon_arrival_time tues_arrival_time wed_arrival_time thurs_arrival_time fri_arrival_time sat_arrival_time sun_arrival_time |
Used to set different arrival times to match your day-specific destinations. | string |
mon_route_name tues_route_name wed_route_name thurs_route_name fri_route_name sat_route_name sun_route_name |
Used to set route names to match your day-specific destinations. | string |
Option | Description | Type | Default |
---|---|---|---|
changeColor |
Set to true to change the color of the module based on traffic. See other options for customization. |
boolean | false |
limitYellow |
Percentage increase in commute time due to traffic to turn commute text yellow. | integer | 10 |
limitRed |
Percentage increase in commute time due to traffic to turn commute text red. | integer | 30 |
showGreen |
Set to false to leave the module white when there's no traffic. |
boolean | true |
colorOnlySymbol |
Set to true to only apply the color change to the symbol, leaving the text white. |
boolean | false |
Use these options to only update your commute information when you need it. This saves bandwidth and API calls.
Option | Description | Type | Default |
---|---|---|---|
showWeekend |
Used to set if the commute time is requested at the weekend. | boolean | true |
allTime |
Used to set if the commute time is requested 24hrs a day. If this is set to false then the startHr and endHr are used to set when the times are displayed. |
boolean | true |
startHr |
Used to set the hour when the commute times are first requested if allTime is false .The range is 0 to 23 . |
integer | 7 |
endHr |
Used to set the hour when the commute times are last requested if allTime is false .The range is 0 to 23 . |
integer | 22 |
hideOffHours |
Used to set if the module will be hidden when outside the days/times designated in the above 4 parameters. | boolean | false |
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",
mon_destination: "116th St & Broadway, New York, NY 10027",
fri_destination: "1 E 161st St, Bronx, NY 10451",
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
}
},