Zum Hauptinhalt springen

NSW Departures (unofficial) Smart-Home-Integration, kostenlos und Open Source

NSW Departures (unofficial)-Integration für Gladys Assistant

Unofficial. Next departures and alerts at your NSW stops (Transport for NSW data).

Info

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

The next departures (trains, metro, light rail, buses, ferries) at up to four stops of New South Wales, and the service alerts in effect there, in Gladys. Data: Transport for NSW, Open Data Hub, licensed under Creative Commons Attribution 4.0.

This integration is unofficial: it is not affiliated with nor endorsed by Transport for NSW, and it is not an official source. Check transportnsw.info or the signs at the stop before you travel. It was never tested with a real key nor on a real Gladys installation by its author: the answers of the Trip Planner were simulated from its official documentation (Swagger file of 2025-10-02, API Basics page).

Get started​

  1. Create the free API key: register on the Open Data Hub, click your profile icon, then API Tokens, type a name and Create API token (user guide). Copy the key at once: the hub shows it only once. Type the key alone (if you paste it with apikey before it, that word is taken away).
  2. Find the stop ids. A station (e.g. 200060 for Central Station: every platform), a platform, a bus stop or a wharf has a number in the Trip Planner: the stop_id of the GTFS timetables of Transport for NSW, or the number in the stop pages of transportnsw.info.
  3. Install the integration, type the key and the ids in its configuration, and save. Open the Discover tab and press Add on each stop. Its name becomes the Trip Planner name ("Central Station (departures)") after the first read, unless you typed one.

One device per stop. A device belongs to a slot and its id: if you type another id in a slot, the integration offers a new device; the old one is no longer updated and keeps its last values (the configuration page lists it under "Not updated any more": delete it in Gladys). Changing the routes filter keeps the device.

What each device shows​

FeatureTypeContent
Next departuretext"T1 → Hornsby in 6 min (12:41, Platform 18, 2 min late)", "due" within a minute, "timetable time" without real time
Following departuretextthe same for the next one
Departures (30 min)counterfor scenes, e.g. "more than 0"
Departurestext"12:35 · T1 → Hornsby 6, 14 min · T9 → Gordon 11 min"
Alerts in effectcounterthe alerts the Trip Planner gives for the stop today
Alerttextthe first alert (highest priority first, then the latest) and how many more

The times are Sydney times. Every read publishes every value: a departure that is gone becomes "No following departure (read 12:36)", never a number left behind. A failed or unreadable read publishes nothing (no 0): the configuration page says why and since when. A departure flagged cancelled is left out. The routes filter keeps only the routes you list, as shown (T1, 333, F1...).

A stop id is checked against the answer: the departures are published only when the Trip Planner names that id (as the stop, a parent of the platform or in its properties). When it names other stops only, the id is said unknown and asked again 30 minutes later; when it names none and there is no departure, nothing is published until the id has been confirmed once.

The scene trigger New service alert at a stop fires once for an alert seen for the first time at a watched stop, when it started within the last 24 hours (the first read only learns the alerts already there). You can keep high priority alerts only ("high" or "veryHigh"), or the others.

Requests and quotas​

  • One request per stop and per read for the departures; the alerts every 5 minutes, one request per stop. Both carry the key and are counted. One request at a time, 1 s apart at least (the hub allows 5 a second).
  • The default "Bronze" plan of the hub grants 60,000 requests a day per key, all the APIs together (API Basics page, read on 2026-12-03). The integration keeps its own daily budget (10,000 by default, 500 to 60,000), counted per Sydney date and written to /data before each request: a restart keeps the count. When the planned reads would use more than 90 % of the budget (80 % of it for the departures, 20 % for the alerts), the intervals are stretched, and the configuration page says so. With 4 stops and 10,000 requests, the defaults hold (60 s, 5 min).
  • A read never comes sooner than the interval: neither a restart, nor a reconnection, nor saving an unchanged configuration, nor Discovery (when /data cannot tell the time of the last read, the first one waits 30 s after the start).
  • "Account Over Rate Limit" or HTTP 429: the key is paused (2 minutes, doubled up to 6 hours, Retry-After respected). "Account Over Quota Limit": the key is paused until 00:05 the next day in Sydney, but 1 to 3 hours only (the hour of the reset is an assumption: the hub is asked again after at most 3 hours). A server error pauses the service that got it (1 minute, doubled up to 6 hours). The pauses are kept in /data.

The key​

The key is kept by Gladys in its database, never shown again, and sent only to Transport for NSW, in the Authorization header (never in a URL). It never appears in the logs, the status nor /data.

When the departures answer HTTP 401 with "The calling application is unauthenticated", the key is refused: nothing is sent with it any more (neither departures nor alerts) until you type another key, or until the button Show the last read / retry the key sends one request with it that succeeds (30 s at least after the previous request). /data keeps two salted 8-bit prints of the refused key, never the key: another key is tried (after a restart, unless both its prints match too: 1 key in 65,536). Any other 401 or 403 (the hub also uses them when a limit is exceeded), and any 401 or 403 of the alerts, is never a refusal: the departures pause, the alerts are spaced out (5 minutes, doubled up to 1 hour).

Clock and time zone​

The answers are used only when their Date header is within 5 minutes of the clock of the machine running Gladys: set its clock (NTP) if the status says it differs. The quota day and the alerts filter use the Sydney date.

Limits​

  • Read-only: nothing is ever sent but reads.
  • The departures of a stop are those the Trip Planner gives for "now" (departure_mon); the alerts those of add_info for the stop and today.
  • The quota day of the hub is assumed to start at midnight in Sydney (not documented).

Licence and attribution​

Data: Transport for NSW (Open Data Hub), under the Creative Commons Attribution 4.0 licence and the Open Data Hub terms: attributed to Transport for NSW, no Transport for NSW logo, nothing suggesting an official status or an endorsement.

Konfigurationseinstellungen​

Diese Einstellungen fragt NSW Departures (unofficial) in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
Departures in New South WalessectionNeinUnofficial, not affiliated with nor endorsed by Transport for NSW. Data: Transport for NSW (Open Data Hub, Creative Commons Attribution 4.0). The next departures (trains, metro, light rail, buses, ferries) at up to four stops of the Trip Planner, and the service alerts in effect there. Needs one free API key of the Open Data Hub (an account, then 'API Tokens'). The key has a daily quota (60,000 requests on the default plan): the integration counts its requests and stays within the daily budget below.
Open Data Hub API keysecretJaThe free API key (token) of the Open Data Hub, kept by Gladys in its database, never shown again, sent only to Transport for NSW (api.transport.nsw.gov.au).
Language of the textsselectNeinThe language of the device names and the departure texts (the Transport for NSW texts stay in English).
Read interval (s)numberNeinHow often the departures are read, in seconds (30 to 600). Stretched when the daily budget would not hold it. The alerts are read every 5 minutes.
Daily budget (requests)numberNeinRequests per Sydney day at most (500 to 60000; the default plan of the hub grants 60000 a day). Each stop costs one request per read, and one more per alerts read.
Stop 1sectionNeinThe stop id of the Trip Planner: a station (e.g. 200060 for Central Station, every platform), a platform, a bus stop or a wharf, as in the GTFS stops of Transport for NSW or the stop pages of transportnsw.info.
Name (optional)stringNein
Stop idstringNein
Routes (optional)stringNeinOnly these routes, comma separated, as shown (e.g. T1, 333, F1). Empty: every route.
Stop 2sectionNeinThe stop id of the Trip Planner: a station (e.g. 200060 for Central Station, every platform), a platform, a bus stop or a wharf, as in the GTFS stops of Transport for NSW or the stop pages of transportnsw.info.
Name (optional)stringNein
Stop idstringNein
Routes (optional)stringNeinOnly these routes, comma separated, as shown (e.g. T1, 333, F1). Empty: every route.
Stop 3sectionNeinThe stop id of the Trip Planner: a station (e.g. 200060 for Central Station, every platform), a platform, a bus stop or a wharf, as in the GTFS stops of Transport for NSW or the stop pages of transportnsw.info.
Name (optional)stringNein
Stop idstringNein
Routes (optional)stringNeinOnly these routes, comma separated, as shown (e.g. T1, 333, F1). Empty: every route.
Stop 4sectionNeinThe stop id of the Trip Planner: a station (e.g. 200060 for Central Station, every platform), a platform, a bus stop or a wharf, as in the GTFS stops of Transport for NSW or the stop pages of transportnsw.info.
Name (optional)stringNein
Stop idstringNein
Routes (optional)stringNeinOnly these routes, comma separated, as shown (e.g. T1, 333, F1). Empty: every route.

So installierst du NSW Departures (unofficial) in Gladys​

  1. Öffne in Gladys Integrationen: NSW Departures (unofficial) 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-nsw-departures: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-nsw-departures.

NSW Departures (unofficial) 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​

NSW Departures (unofficial) 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 🙂