A module for the MagicMirror² smart mirror platform.
It displays travel time between two locations using the TomTom Routing API (Calculate Route), optionally factoring in live traffic conditions.
From your MagicMirror installation directory, run:
cd modules
git clone https://github.com/jennyo88/MMM-Traffic.git
cd MMM-Traffic
npm installThis fork is preconfigured to use TomTom instead of Mapbox.
- Create a TomTom Developer account.
- Go to Dashboard → My Keys → Add a new key.
- Enable Routing API for your key.
- Copy your key and add it to your module configuration as
tomtomKey. - No credit card is required — TomTom offers a generous free tier (up to 2,500 requests per day) for developers and hobby projects.
Tip: If you plan to use multiple MMM-Traffic modules or refresh frequently, you can create multiple free keys under the same account.
You can use the global MagicMirror CSS override file to customize the look of each line:
.mmmtraffic-firstline {
font-size: 40px;
color: yellow;
}
.mmmtraffic-secondline {
color: green;
}Classes:
.mmmtraffic-firstline.mmmtraffic-secondline
Get your coordinates from Google Maps or OpenStreetMap.
Note: TomTom expects coordinates in latitude,longitude, but this module’s config uses longitude,latitude and converts automatically.
| Option | Description | Type | Example |
|---|---|---|---|
tomtomKey |
Your TomTom API key. | string | 'YOUR_TOMTOM_KEY' |
originCoords |
Origin location (longitude,latitude). |
string | '-118.2437,34.0522' |
destinationCoords |
Destination location (longitude,latitude). |
string | '-118.3533,34.1016' |
waypoints |
Optional array of longitude,latitude waypoints. |
array | ['-118.2915,34.0736'] |
| Option | Description | Type | Default Value | Supported Values |
|---|---|---|---|---|
mode |
Type of travel. | string | 'driving' |
'driving', 'walking', 'cycling' |
language |
Language for route guidance text. | string | config.language |
e.g., 'en-US', 'es-ES' |
interval |
Refresh interval in milliseconds. | number | 300000 (5 minutes) |
|
showSymbol |
Show a travel mode icon. | boolean | true |
|
routeType |
TomTom route type. | string | 'fastest' |
'fastest', 'eco', 'shortest' |
useTraffic |
Include live traffic in ETA (car mode only). | boolean | true |
|
includeNoTrafficBaseline |
Compute both normal and no-traffic times. | boolean | true |
Customize text and placeholders:
| Option | Description | Type | Default |
|---|---|---|---|
loadingText |
Text displayed while fetching data. | string | 'Loading...' |
firstLine |
Primary text line. | string | 'Current duration is {duration} mins' |
secondLine |
Optional second line (smaller text). | string | undefined |
| Token | Replaced With |
|---|---|
{duration} |
Travel time in minutes (from TomTom API). |
{route} |
Route label or first instruction (from TomTom guidance). |
Hide the module on certain days or time windows to save API calls.
| Option | Description | Type | Default |
|---|---|---|---|
days |
Days of week to display (0=Sunday). | array | [0,1,2,3,4,5,6] |
hoursStart |
Start time (24h format). | string | "00:00" |
hoursEnd |
End time (24h format). | string | "23:59" |
{
module: "MMM-Traffic",
position: "top_left",
config: {
tomtomKey: "YOUR_TOMTOM_KEY",
originCoords: "-118.2437,34.0522",
destinationCoords: "-118.3533,34.1016"
}
}{
module: "MMM-Traffic",
position: "top_left",
config: {
tomtomKey: "YOUR_TOMTOM_KEY",
originCoords: "-118.2437,34.0522",
destinationCoords: "-118.3533,34.1016",
showSymbol: false,
firstLine: "{duration} mins"
}
}{
module: "MMM-Traffic",
position: "top_left",
config: {
tomtomKey: "YOUR_TOMTOM_KEY",
originCoords: "-118.2437,34.0522",
destinationCoords: "-118.3533,34.1016",
firstLine: "{duration} mins",
secondLine: "via {route}"
}
}{
module: "MMM-Traffic",
position: "top_left",
config: {
tomtomKey: "YOUR_TOMTOM_KEY",
originCoords: "-118.2437,34.0522",
destinationCoords: "-118.3533,34.1016",
waypoints: ["-118.2915,34.0736"],
firstLine: "{duration} mins",
secondLine: "with stop"
}
}{
module: "MMM-Traffic",
position: "top_left",
config: {
tomtomKey: "YOUR_TOMTOM_KEY",
originCoords: "-118.2437,34.0522",
destinationCoords: "-118.3533,34.1016",
firstLine: "{duration} mins",
secondLine: "Home to Work"
}
},
{
module: "MMM-Traffic",
position: "top_left",
config: {
tomtomKey: "YOUR_TOMTOM_KEY",
originCoords: "-118.2437,34.0522",
destinationCoords: "-118.2437,34.1016",
firstLine: "{duration} mins",
secondLine: "Home to Gym"
}
}{
module: "MMM-Traffic",
position: "top_left",
config: {
tomtomKey: "YOUR_TOMTOM_KEY",
originCoords: "-118.2437,34.0522",
destinationCoords: "-118.3533,34.1016",
firstLine: "{duration} mins",
secondLine: "Work",
days: [1,2,3,4,5],
hoursStart: "07:00",
hoursEnd: "09:00"
}
}- moment
- (If your Node version lacks global fetch) node-fetch
This module uses the TomTom Routing API – Calculate Route.
Base URL
https://api.tomtom.com/routing/1/calculateRoute/{lat,lon:...}/json
Core Parameters Used
key— your TomTom API keytravelMode—car,bicycle, orpedestrianrouteType—fastest(default),shortest, orecotraffic—trueto include live/historic traffic (car mode recommended)language— e.g.,en-US,es-ESinstructionsType—textfor readable guidance (used to populate{route})computeTravelTimeFor—allto include baseline times (optional; availability may vary)
See: https://developer.tomtom.com/routing-api/documentation/tomtom-maps/calculate-route
If you prefer the original Mapbox or the older Google Maps implementation, see:
- Mapbox version (main): https://github.com/SamLewis0602/MMM-Traffic
- Google Maps version (unsupported): https://github.com/SamLewis0602/MMM-Traffic/tree/1.0-not-supported
Note: Those versions are not part of this TomTom edition and may not receive updates here.
