Skip to content

A MagicMirror² module that shows real-time travel times and routes using the TomTom Routing API — no credit card required to get your free API key.

Notifications You must be signed in to change notification settings

jennyo88/MMM-Traffic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

532 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MMM-Traffic (TomTom Edition)

module screenshot

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.


Table of Contents


Installation

From your MagicMirror installation directory, run:

cd modules
git clone https://github.com/jennyo88/MMM-Traffic.git
cd MMM-Traffic
npm install

This fork is preconfigured to use TomTom instead of Mapbox.


TomTom API Key (No Credit Card Required)

  1. Create a TomTom Developer account.
  2. Go to Dashboard → My Keys → Add a new key.
  3. Enable Routing API for your key.
  4. Copy your key and add it to your module configuration as tomtomKey.
  5. 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.


Styling

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

Configuration

Required

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']

Basic Options

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

Translation/Display

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

Tokens

Token Replaced With
{duration} Travel time in minutes (from TomTom API).
{route} Route label or first instruction (from TomTom guidance).

Per Day/Time Customization

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"

Examples

Simplest Config

{
  module: "MMM-Traffic",
  position: "top_left",
  config: {
    tomtomKey: "YOUR_TOMTOM_KEY",
    originCoords: "-118.2437,34.0522",
    destinationCoords: "-118.3533,34.1016"
  }
}

Minimal Look

{
  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"
  }
}

Use both lines

{
  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}"
  }
}

Using Waypoints

{
  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"
  }
}

Multiple Routes

{
  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"
  }
}

Per Day Customization

{
  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"
  }
}

Dependencies


API Reference

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 key
  • travelModecar, bicycle, or pedestrian
  • routeTypefastest (default), shortest, or eco
  • traffictrue to include live/historic traffic (car mode recommended)
  • language — e.g., en-US, es-ES
  • instructionsTypetext for readable guidance (used to populate {route})
  • computeTravelTimeForall to include baseline times (optional; availability may vary)

See: https://developer.tomtom.com/routing-api/documentation/tomtom-maps/calculate-route


Legacy

If you prefer the original Mapbox or the older Google Maps implementation, see:

Note: Those versions are not part of this TomTom edition and may not receive updates here.

About

A MagicMirror² module that shows real-time travel times and routes using the TomTom Routing API — no credit card required to get your free API key.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.2%
  • CSS 1.8%