Zum Hauptinhalt springen

Mapbox Traffic Smart-Home-Integration, kostenlos und Open Source

Mapbox Traffic-Integration für Gladys Assistant

Live traffic on your routes: travel time, delay, charts and traffic jam alerts via Mapbox.

Info

Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfügbar.

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:

FeatureDescription
Travel timeDuration with the current traffic, in minutes (kept in history)
Usual travel timeTypical duration at this time of the week according to Mapbox
DelayDifference between both, in minutes
DistanceLength of the recommended route, in km
Traffic level0 fluid, 1 moderate, 2 traffic jam, 3 severe jam
TrafficThe same level as a text
ViaThe 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​

  1. 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.
  2. In the integration Configuration tab, paste the token.
  3. 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).
  4. Click Test Mapbox: the current travel time of route 1 shows under the button.
  5. 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/Paris by 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; set LOG_LEVEL=debug to see the requests (the token is masked).

Konfigurationseinstellungen​

Diese Einstellungen fragt Mapbox Traffic in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
Mapbox accountsectionNeinCreate a free Mapbox account and copy your default public access token (it starts with pk.).
Mapbox free plansectionNeinThe 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 tokensecretJa
Language of the textsselectNein
Route 1sectionNeinA 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.
NamestringNein
Origin (leave empty to start from your home)stringNein
DestinationstringJa
Route 2sectionNeinOptional extra route, same format as route 1.
NamestringNein
Origin (leave empty to start from your home)stringNein
DestinationstringNein
Route 3sectionNeinOptional extra route, same format as route 1.
NamestringNein
Origin (leave empty to start from your home)stringNein
DestinationstringNein
RefreshsectionNeinRoutes 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)numberNein
Active days (empty = every day)multi_selectNein
Active hours (empty = all day)stringNein
TimezonestringNein
Avoidmulti_selectNein
AlertssectionNeinA 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 (%)numberNein
Abnormal: longer than usual by (%)numberNein
Abnormal: and at least (min) latenumberNein

So installierst du Mapbox Traffic in Gladys​

  1. Öffne in Gladys Integrationen: Mapbox Traffic erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
  2. Klicke auf Installieren. Gladys lädt das Docker-Image (ghcr.io/quentinlegay/gladys-mapbox-traffic:1.0.3) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die Oberfläche der Integration (Geräte, Erkennung und Konfiguration).
  3. Öffne den Bildschirm Konfiguration der Integration, fülle die Einstellungen aus und speichere.
  4. Du kannst sie auch direkt über die URL ihres Repositorys installieren: https://github.com/quentinlegay/Gladys-mapbox-traffic.

Mapbox Traffic benötigt Gladys >=5.1.0. Der Katalog in Gladys wird stündlich aktualisiert, eine neue Version ist also spätestens eine Stunde nach ihrer Veröffentlichung verfügbar.

Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.

Über externe Integrationen​

Mapbox Traffic ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und führt sie in einer vom Kern isolierten Sandbox aus. Sie wird von quentinlegay veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.

Abonniere den Newsletter von Gladys Assistant

Ein paar E-Mails im Monat zu neuen Releases und Neuigkeiten aus dem Projekt. Verschickt von Pierre-Gilles Leymarie, dem Gründer des Projekts. Jederzeit abbestellbar 🙂