Zum Hauptinhalt springen

Västra Götaland Transit Smart-Home-Integration, kostenlos und Open Source

Västra Götaland Transit-Integration für Gladys Assistant

Unofficial. Next departures and disruptions at your Västra Götaland stops (Västtrafik open data).

Info

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

Unofficial integration, not affiliated with Västtrafik. It shows, in Gladys, the next departures (trams, buses, boats, trains) at up to four stop areas of Västra Götaland and the traffic situations in effect there. The data comes from the open APIs of Västtrafik (CC0 1.0): Planera Resa v4 for the departures, Traffic Situations v1 for the disruptions.

This version was never tested with a real key: it was written from the official definitions of the APIs (OpenAPI of Planera Resa v4, Swagger of Traffic Situations v1, the OAuth 2 guide of the portal) and tested against simulated answers. Please report what you see with a real key.

What you need​

  1. A free account on the Västtrafik developer portal.
  2. An application registered there, subscribed to Planera Resa v4 and to Traffic Situations ("Störning"). A subscription added later is seen with the next access token (within 24 hours) or after a restart of the integration.
  3. The key and the secret of that application, copied into the configuration. Gladys keeps them in its database, does not show them again, and sends them only to Västtrafik (to ask an access token). The terms of the portal forbid giving your key to anyone else: each Gladys uses its own application.

Configuration​

  • Key and Secret: both, or nothing is sent.
  • Language of the texts: English or French for the device names and the departure texts. Stop names, destinations and traffic situations stay as Västtrafik sends them (mostly Swedish).
  • Read interval: 30 to 600 seconds (60 by default) for the departures. The traffic situations are read every 5 minutes.
  • Stop 1 to 4: the 16-digit gid of a stop area (e.g. 9021014001760000 for Brunnsparken, 9021014008000000 for Göteborg Centralstationen), an optional name, optional platforms (A, C2: only those platforms) and optional lines (6, 11, GRÖN: only those lines; a traffic situation naming other lines only is left out). The gid is the one the Planera Resa search locations/by-text gives.

Devices​

One device per stop, read-only, with:

  • Next departure and Following departure (texts): 6 → Kortedala in 4 min (09:18, platform C, 2 min late). The time is the real-time estimate when Västtrafik has one, else the timetable time (said so). A cancelled departure is left out; a partly cancelled one is marked. When there is none: No departure (read 09:14).
  • Departures (30 min) (counter): the departures within the next 30 minutes.
  • Departures (text): a summary by line and destination, with the time of the read.
  • Traffic situations in effect (counter) and Traffic situation (text: the most severe one, and how many more).

A failed or unreadable read publishes nothing: the previous values stay, with their read time in the texts, and the status of the integration says since when nothing was published. A stop area that Västtrafik does not know (or that has no traffic soon: the API gives the same answer, 404) is asked again 30 minutes later; once Västtrafik has answered for that gid, a 404 means "no departure".

Scene trigger​

New traffic situation at a stop: a situation in effect appears for the first time at a watched stop, started within the last 24 hours. The first read after a start, or after a change of the stop, only learns what is there. Optional filter on the severity (severe, normal, slight). Variables: title, description, severity, situation number, lines.

Pace and courtesy​

The terms of the portal ask to keep the use to what the purpose needs; Västtrafik publishes no numeric quota.

  • One request at a time, 1 second at least between two.
  • One departures request per stop and per read; the traffic situations every 5 minutes per stop.
  • One access token, kept in memory (not in /data) and used until it expires (24 hours, renewed when less than 30 seconds are left). Two token requests are 60 seconds apart at least; after a restart, a new token is asked.
  • A 401 on a token that the same API answered before: one new token and one retry. A 401 or 403 on a new token means the application lacks the subscription: that API is asked again later (2 minutes, doubled up to 1 hour), the key and secret are not taken as refused.
  • 429 and server errors pause that service (the Retry-After of Västtrafik when longer, 1 minute to 6 hours, doubled each time), kept in /data over a restart.
  • Refused key and secret (the token server answers 401 or invalid_client): nothing is sent with them until they change, or until the button Show the last read / retry the key gets a token (one token request per press, 30 seconds apart at least). Only two salted 8-bit prints of the pair are kept in /data, never the key, the secret nor the token.
  • A restart, a reconnection, a saved unchanged configuration, Discovery or the button do not read sooner than the interval (the time of the last read is kept in /data).

Privacy​

The key, the secret and the access token travel in HTTP headers to ext-api.vasttrafik.se only. They are not written in the logs, in /data, in the status nor in an error. /data holds the time of the last read, the pauses, the prints of refused credentials, and salted fingerprints of the stops with the numbers of the traffic situations already announced.

Data and license​

Västtrafik data is published under CC0 1.0. Västtrafik provides its APIs "as is", without guarantee of availability or accuracy. The integration is not a ticket app and uses no logo nor brand of Västtrafik.

Konfigurationseinstellungen​

Diese Einstellungen fragt Västra Götaland Transit in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
Västtrafik departures and traffic situationssectionNeinUnofficial, not affiliated with Västtrafik. Data from the open APIs of Västtrafik (CC0 1.0): the next departures at up to four stop areas of Västra Götaland (Planera Resa v4) and the traffic situations in effect there (Traffic Situations). Create a free account on the Västtrafik developer portal, register an application, subscribe it to "Planera Resa v4" and "Traffic Situations", and copy its key and secret here. The integration keeps its use to what it needs, as the portal's terms ask: one request per stop and per read, the traffic situations every 5 minutes, one access token for 24 hours.
Key of the applicationsecretNeinThe key (client identifier) of your application on the Västtrafik portal, kept by Gladys in its database, never shown again, sent only to Västtrafik.
Secret of the applicationsecretNeinThe secret of the same application, kept by Gladys in its database, never shown again, sent only to Västtrafik.
Language of the textsselectNeinThe language of the device names and the departure texts (stop names, destinations and traffic situations stay as Västtrafik sends them, mostly in Swedish).
Read interval (s)numberNeinHow often the departures are read, in seconds (30 to 600). The traffic situations are read every 5 minutes.
Stop 1sectionNeinThe 16-digit gid of a stop area (e.g. 9021014001760000 for Brunnsparken, 9021014008000000 for Göteborg Centralstationen). It is the stop area id in the address of a stop on vasttrafik.se, or the gid that the Planera Resa "locations/by-text" search gives.
Name (optional)stringNein
Stop area gidstringNein
Platforms (optional)stringNeinOnly these platforms (Läge), comma separated, as Västtrafik names them (e.g. A, C2). Empty: every platform.
Lines (optional)stringNeinOnly these lines, comma separated, as shown to travellers (e.g. 6, 11, GRÖN). Empty: every line. A traffic situation naming other lines only is left out.
Stop 2sectionNein
Name (optional)stringNein
Stop area gidstringNein
Platforms (optional)stringNeinOnly these platforms (Läge), comma separated, as Västtrafik names them (e.g. A, C2). Empty: every platform.
Lines (optional)stringNeinOnly these lines, comma separated, as shown to travellers (e.g. 6, 11, GRÖN). Empty: every line. A traffic situation naming other lines only is left out.
Stop 3sectionNein
Name (optional)stringNein
Stop area gidstringNein
Platforms (optional)stringNeinOnly these platforms (Läge), comma separated, as Västtrafik names them (e.g. A, C2). Empty: every platform.
Lines (optional)stringNeinOnly these lines, comma separated, as shown to travellers (e.g. 6, 11, GRÖN). Empty: every line. A traffic situation naming other lines only is left out.
Stop 4sectionNein
Name (optional)stringNein
Stop area gidstringNein
Platforms (optional)stringNeinOnly these platforms (Läge), comma separated, as Västtrafik names them (e.g. A, C2). Empty: every platform.
Lines (optional)stringNeinOnly these lines, comma separated, as shown to travellers (e.g. 6, 11, GRÖN). Empty: every line. A traffic situation naming other lines only is left out.

So installierst du Västra Götaland Transit in Gladys​

  1. Öffne in Gladys Integrationen: Västra Götaland Transit erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
  2. Klicke auf Installieren. Gladys lädt das Docker-Image (ghcr.io/lm1lc3n7/gladys-vastra-gotaland-transit:0.1.1) 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/LM1LC3N7/gladys-vastra-gotaland-transit.

Västra Götaland Transit benötigt Gladys >=5.3.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​

Västra Götaland Transit 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 LM1LC3N7 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 🙂