MMM-Traffic

February 15, 2026 ยท View on GitHub

module screenshot

This a module for the MagicMirror. It displays travel time between two locations, using the Mapbox directions API to factor in current traffic conditions.

Table of Contents

Installation

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

Mapbox Access Token

  1. Create an account at Mapbox
  2. Copy the access token visible after account creation (go here if you don't see it)

Styling

You can use a global MagicMirror/css/custom.css file to customize the styles for each line of MMM-Traffic separately. Each line has its own class that should be used to apply styles:

  • .mmmtraffic-firstline
  • .mmmtraffic-secondline

For example, this css

.mmmtraffic-firstline {
  font-size: 40px;
  color: yellow;
}

.mmmtraffic-secondline {
  color: green;
}

leads to this abomination: css example screenshot

Configuration

Required

See here for instructions on how to use Google Maps webpage/app to get coordinates for your origin/destination.

Note: Google maps coordinates are latitude,longitude, but Mapbox uses longitude,latitude so be sure to reverse what you copy from Google.

OptionDescriptionTypeExample
accessTokenMapbox access tokenstring-
originCoordslongitude,latitude of the origin location.string'-84.504259,33.882107'
destinationCoordslongitude,latitude of the origin location.string'-84.504259,33.882107'
waypointsOptional array of longitude,latitude waypoints between origin and destination.array['-81.307398,28.411692', '-81.570944,28.393389']

Basic Options

OptionDescriptionTypeDefault ValueSupported Options
modeChange the module to cycling or walking.string'driving''walking' 'cycling'
languageDefine the commute time language.stringconfig.languageAny language string
intervalHow often the traffic is updated in milliseconds.integer300000
(5 minutes)
showSymbolWhether to show the car symbol or not.booleantrue

Translation/Display

Use these options to customize/translate the module's text.

*Note: See tokens below to see what tokens will be replaced with real values in firstLine/secondLine.

OptionDescriptionTypeDefault ValueToken Replacement
loadingTextThe text used when loading the initial duration.string'Loading...':x:
firstLineThe main line of the modulestring'Current duration is {duration} mins':heavy_check_mark:
secondLineThe second line of the module, appears below the first line in smaller, dimmer textstringundefined:heavy_check_mark:

Tokens

TokenValue
{duration}The total driving time in minutes returned from the mapbox API
{hours}The hours portion of the driving time (e.g., 2 for a 125 min trip)
{leftoverMinutes}The remaining minutes after hours (e.g., 5 for a 125 min trip)
{route}The summary of the route from the mapbox API

Per Day/Time Customization

Using these options to hide the module when you're not using it will save API calls, allowing you to have a shorter interval or more MMM-Traffic modules without getting rate limited.

OptionDescriptionTypeDefault
daysWhich days of the week to show the traffic module, with 0 being SundayArray[int][0, 1, 2, 3, 4, 5, 6]
hoursStartWhat time to begin showing the module on the days it shows, 24 hour timeString"00:00"
hoursEndWhat time to stop showing the module on the days it shows, 24 hour timeString"23:59"

Examples

Simplest Config

{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
	}
},

simple config screenshot

Minimal Look

{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		showSymbol: false,
		firstLine: "{duration} mins"
	}
},

minimal screenshot

Use both lines

{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		firstLine: "{duration} mins",
		secondLine: "Coffee Run"
	}
},

both lines custom screenshot

Use both lines with route

{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		firstLine: "{duration} mins",
		secondLine: "via {route}"
	}
},

both lines with route screenshot

Using waypoints

{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		waypoints: ["-84.456210,33.876496"],
		firstLine: "{duration} mins",
		secondLine: "with stops"
	}
},

Multiple Routes

{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		firstLine: "{duration} mins",
		secondLine: "Home To School",
	}
},
{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		firstLine: "{duration} mins",
		secondLine: "Home To Work"
	}
},

multiple routes screenshot

Per day customization

This setup would show one route for Monday, Wednesday, and Friday, and another for Tuesday and Thursday. It would only show between 07:00 and 09:00 each day. It would be completely hidden on weekends.

{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		firstLine: "{duration} mins",
		secondLine: "School",
		days: [1,3,5],
		hoursStart: "07:00",
		hoursEnd: "09:00"
	}
},
{
	module: "MMM-Traffic",
	position: "top_left",
	config: {
		accessToken: "your_key_here",
		originCoords: "-84.398848,33.755165",
		destinationCoords: "-84.504259,33.88210",
		firstLine: "{duration} mins",
		secondLine: "Work",
		days: [2,4],
		hoursStart: "07:00",
		hoursEnd: "09:00"
	}
},
DayView
Mon/Wed/Friminimal screenshot
Tu/Thminimal screenshot

Dependencies

Legacy

If you want to continue using the old version with Google Maps and more customization, use the 1.0-not-supported branch.

NOTE: this version is no longer supported, please do not open issues on the repo if you run into issues with this version.