Skip to content

RedNax67/MMM-TrafficCal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MMM-TrafficCal

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.

Installation

  1. Navigate into your MagicMirror's modules folder and execute git clone https://github.com/RedNax67/MMM-TrafficCal.git. A new folder will appear, navigate into it.
  2. Execute npm install to install the node dependencies.

Config

The entry in config.js can include the following options:

Option Description
apiKey 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
tripkey A keyword so the module can identify commutes you want to display. You'll have to start the calender entry title with this word
Example: 'MYTRIP'

This value is REQUIRED
mode Mode of transportation.

Default value: 'driving'
Other Options:'walking' 'bicycling' 'transit'
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
insteadofText Define an 'instead of' string
viaText Define a 'via' string

Here is an example of an entry in config.js

{
	module: 'MMM-TrafficCal',
	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',
        tripkey: 'MYTRIP',
		origin: '4 Pennsylvania Plaza, New York, NY 10001',
		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
        insteadofText: 'instead of',
        viaText: 'via'
        
	}
},

It's advisable to create an extra calendar just for trips so you can set maximumNumberOfDays: 1 for it and just get todays commutes. You can hide this extra calender so it won't be displayed on your mirror but will still drive this module. In the description field of the appointment you can enter: [[commutealias]:[alternate commute origin]]. The alternate origin could be useful to show people at home/mirror location how long your incoming commute will take.

Dependencies

  • request (installed via npm install)
  • [calendar] You'll need to add entries in your calendar starting with the tripkey keyword and the full (google suggested) address for your destination. Add the text you want prepended in the remarks field in the appointment.

Important Notes

Special Thanks

About

Display commutes based on calendar entries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published