Integración domótica Mapbox Traffic, gratuita y de código abierto

Live traffic on your routes: travel time, delay, charts and traffic jam alerts via Mapbox.
La documentación de esta integración la escribe su autor y, por ahora, solo está disponible en inglés.
Track the travel time of your usual routes (home → work, school…) with live
traffic, see it as a chart and get notified of traffic jams or abnormally long
trips. Data comes from the
Mapbox Directions API
(driving-traffic profile).
What you get
One route device per configured route (up to 3), with:
| Feature | Description |
|---|---|
| Travel time | Duration with the current traffic, in minutes (kept in history) |
| Usual travel time | Typical duration at this time of the week according to Mapbox |
| Delay | Difference between both, in minutes |
| Distance | Length of the recommended route, in km |
| Traffic level | 0 fluid, 1 moderate, 2 traffic jam, 3 severe jam |
| Traffic | The same level as a text |
| Via | The main roads taken ("A86, A1") |
Plus:
- a dashboard widget "Travel time": duration, delay, chart of the current vs usual travel time, traffic status and a "Refresh" button;
- four scene triggers: Traffic jam on a route, Traffic jam cleared, Abnormally long travel time, Travel time back to normal;
- a scene action Get the travel time of a route, e.g. to send "32 min (+7 min) · Moderate" every morning.
Setup
- Create a free account on mapbox.com and copy
your default public access token (it starts with
pk.). The free tier includes 100,000 route requests a month. - In the integration Configuration tab, paste the token.
- Fill in at least route 1:
- Name: "Work" for instance;
- Origin: leave empty to start from the home location set in Gladys (Settings → Houses), or type an address or coordinates;
- Destination: an address or "latitude, longitude" coordinates ("48.8924, 2.2369", as copied from Google Maps with a right click).
- Click Test Mapbox: the current travel time of route 1 shows under the button.
- Open the Discovery tab and add your routes.
Refresh
- Interval: 300 s by default (60 s minimum).
- Active days / Active hours: only query Mapbox when it matters, e.g.
Monday to Friday,
07:00-09:30, 16:30-19:00. Empty means always. Hours are read in the configured timezone (Europe/Parisby default). - Avoid: tolls, motorways, ferries.
Mapbox free plan
The Directions API includes 100,000 free requests a month; beyond that, Mapbox bills the extra requests (see the Mapbox pricing). The integration makes one request per route at every refresh, and geocodes each address only once. Monthly usage ≈ routes × refreshes per hour × active hours per day × days.
For example, 3 routes refreshed every 5 minutes for 5 hours each working day use about 4,000 requests a month, and about 26,000 when refreshed all day long: both stay within the free plan. Refreshing 3 routes every minute, 24/7, uses about 130,000 requests and goes over it.
Your actual usage is shown in your Mapbox account.
Alerts
- Traffic jam: at least 10 % (configurable) of the distance is in heavy congestion according to Mapbox, or the trip is clearly longer than usual (+35 %).
- Abnormally long: the travel time exceeds the usual one by 30 % and by at least 5 minutes (both configurable), so a short trip going from 4 to 6 minutes does not alert.
Scene examples
- Traffic jam alert: trigger Traffic jam on a route (route "Work"),
action "Send a message":
Jam to work: {{triggerEvent.data.summary}}. - Morning briefing: at 7 a.m. on weekdays, action Get the travel time of a route, then "Send a message" with the Summary (or Travel time (min)) variable produced by the previous action.
- Personal threshold: the route is a standard Gladys device, so the native "Device value" trigger works too: "when Travel time (Work) > 45".
Event triggers only fire on a change (a single "Traffic jam" while the jam lasts).
Troubleshooting
- "Mapbox refused the access token": check the token on account.mapbox.com.
- Address not found: use a more complete address, or coordinates.
- "the home has no location": set the home location in Gladys, or fill in the origin.
- The integration logs (Logs tab, or
docker logs) detail every refresh; setLOG_LEVEL=debugto see the requests (the token is masked).
Parámetros de configuración
Estos son los parámetros que Mapbox Traffic te pide en su pantalla de configuración en Gladys.
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| Mapbox account | section | No | Create a free Mapbox account and copy your default public access token (it starts with pk.). |
| Mapbox free plan | section | No | The Directions API includes 100,000 free requests a month; beyond that, Mapbox bills the extra requests. This integration makes one request per route at every refresh (addresses are geocoded only once). Monthly usage ≈ routes × refreshes per hour × active hours per day × days. Examples: 3 routes every 5 min, 5 h per working day ≈ 4,000 requests (free); 3 routes every 5 min, 24/7 ≈ 26,000 (free); 3 routes every minute, 24/7 ≈ 130,000 (over the free plan). Use the active days and hours below to stay well within it. |
| Mapbox access token | secret | Sí | |
| Language of the texts | select | No | |
| Route 1 | section | No | A place is either an address ("10 rue de Rivoli, Paris") or coordinates as "latitude, longitude" ("48.8566, 2.3522", as copied from Google Maps). Leave the origin empty to start from the home location set in Gladys. Leave the destination empty to disable the route. |
| Name | string | No | |
| Origin (leave empty to start from your home) | string | No | |
| Destination | string | Sí | |
| Route 2 | section | No | Optional extra route, same format as route 1. |
| Name | string | No | |
| Origin (leave empty to start from your home) | string | No | |
| Destination | string | No | |
| Route 3 | section | No | Optional extra route, same format as route 1. |
| Name | string | No | |
| Origin (leave empty to start from your home) | string | No | |
| Destination | string | No | |
| Refresh | section | No | Routes are only refreshed during the active days and hours, to save your Mapbox quota. Leave them empty to refresh all the time. |
| Refresh interval (s) | number | No | |
| Active days (empty = every day) | multi_select | No | |
| Active hours (empty = all day) | string | No | |
| Timezone | string | No | |
| Avoid | multi_select | No | |
| Alerts | section | No | A traffic jam is detected when at least the given share of the route is in heavy congestion. The travel time is abnormally long when it exceeds the usual one by both the given percentage and the given number of minutes. Both fire scene triggers. |
| Traffic jam: congested share of the route (%) | number | No | |
| Abnormal: longer than usual by (%) | number | No | |
| Abnormal: and at least (min) late | number | No |
Cómo instalar Mapbox Traffic en Gladys
- En Gladys, abre Integraciones: Mapbox Traffic aparece en el catálogo junto a las integraciones nativas, con una insignia de comunidad.
- Haz clic en Instalar. Gladys descarga la imagen Docker (
ghcr.io/quentinlegay/gladys-mapbox-traffic:1.0.3), la ejecuta en un entorno aislado del núcleo y genera la interfaz de la integración (dispositivos, descubrimiento y configuración). - Abre la pantalla de Configuración de la integración, rellena los parámetros y guarda.
- También puedes instalarla directamente desde la URL de su repositorio: https://github.com/quentinlegay/Gladys-mapbox-traffic.
Mapbox Traffic requiere Gladys >=5.1.0. El catálogo de Gladys se actualiza cada hora, así que una nueva versión está disponible como máximo una hora después de publicarse.
¿Todavía no usas Gladys? Es gratuito y de código abierto: sigue la guía de instalación para empezar.
Sobre las integraciones externas
Mapbox Traffic es una integración externa: una integración comunitaria empaquetada como contenedor Docker y publicada en GitHub. Gladys la instala con un clic y la ejecuta en un entorno aislado del núcleo. La publica y mantiene quentinlegay, no el equipo principal de Gladys.
- Explorar todas las integraciones externas
- Descubrir las integraciones nativas incluidas en Gladys
- Crear y publicar tu propia integración externa
- Código fuente en GitHub — fuente de esta documentación