SF Bay Area Transit Smart-Home-Integration, kostenlos und Open Source

Unofficial. Next departures and alerts at your SF Bay Area stops, data provided by 511.org.
Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfügbar.
The next departures and the service alerts at up to five stops of the San Francisco Bay Area (Muni, BART, Caltrain, AC Transit, SamTrans, VTA, Golden Gate Transit, ferries...), in Gladys. Data provided by 511.org (511.org).
This integration is unofficial: it is not affiliated with 511, MTC nor any transit operator, and it is not an official source. Check 511.org or the operator before you travel. It was never tested with a real 511 token nor on a real Gladys installation by its author: it was written from the 511 specification and tested against a simulated 511 that follows it.
Get started in 4 steps
-
Get a free 511 token on 511.org/open-data/token: you receive it by e-mail. Accepting the 511 terms is your choice: you are the one who receives the data.
-
Find your stop. You need the 511 id of the operator and the stop code:
Operator Id Muni (SFMTA) SFBART BACaltrain CTAC Transit ACSamTrans SMVTA SCGolden Gate GGThe stop code is on the sign of most bus stops (Muni: 5 digits, e.g.
15553), and in the stop list of the operator on 511.org. A parent station code gives every platform of the station. -
Install the integration from the catalog, paste the token in 511 token, type the operator and the stop code in Stop 1, and save.
-
Open the Discover tab and press Add on the stop.
One device per stop. A device belongs to a slot, its operator and its stop code: typing another stop in a slot offers a new device; the old one is no longer updated (delete it in Gladys). Changing the line filter keeps the device.
The quota of the token
A 511 token allows 60 requests per hour by default (511 can raise it on request: type your limit in Hourly limit of your token). The integration:
- reads each stop with one request per read (511 answers one stop per request), and the alerts with one request per operator every 15 minutes or more;
- plans the intervals so that no hour holds more than 90 % of your limit: with the default limit, 1 stop every 5 minutes plus its alerts is 16 requests an hour; 5 stops of 3 operators are read every 8 minutes (52 an hour). When your interval does not fit, it is lengthened and the status says so;
- counts every request it sends and never sends one when the last hour
already holds 90 % of the limit (it waits up to 2 minutes for a slot, else
that read is skipped and the status says so). The count is written to
/databefore the request leaves, so a restart knows it. When/datacannot tell it (unreadable file), the first reads wait one interval; - stops every read when 511 answers 429: for the time it asks, 10
minutes at least (doubled on the next ones), 6 hours at most, kept across a restart;
a 5xx or another refusal of the departures (403...) pauses every read 2
minutes (doubled, 6 hours at most); a failed alerts read waits 15 minutes,
then 30, 60, 120 for that operator only, also across a restart (the time of
the attempt is written to
/databefore the request leaves).
Discovery, the Show the last reads button and saving an unchanged configuration never read 511 (saving the configuration again only tries a token refused before a restart once more).
What each device holds
The name of the Next departure feature ends with "(data provided by
511.org)", the others with "(511.org)": the attribution 511 asks for, next to
the data. The minutes of a text are counted at the time of the read: with a
long interval, read the clock time (10:03), which stays right.
- Next departure and Following departure: texts with the line, the
destination, the minutes to wait (counted against the time of the 511
answer) and the clock time, e.g.
14 MISSION → Downtown: 3 min (10:03);, scheduledwhen the operator gives only the timetable time. When there is none:No predicted departure (read 10:05). They are texts so that a departure that no longer exists is never left on the dashboard as a number. - Departures within 60 min: a counter, for the scenes.
- Service alerts: how many alerts are in effect now for the stop, its lines or its whole operator.
- Alert: the text of the first one, e.g.
Line 49 detour. (+1 more), orNo alert (read 10:05).
The lines of a stop, for the alerts, are the lines you filtered, else the lines 511 showed at the stop (kept 7 days). Until a first departure is seen, the alert count of the stop waits (the status says so): a count made without the lines of the stop would miss their alerts. A line that has not called at the stop for 7 days is forgotten.
Never a made-up value
-
An alerts feed without a header time is not used (its age is unknown): no "No alert" from it.
-
A line filter that matches none of the departures 511 shows at the stop, three reads in a row, is said in the status: check the line names.
-
A read that failed, an answer that cannot be read (one departure whose time cannot be read refuses the whole answer), an answer whose time differs from the clock of the machine by more than 5 minutes: nothing is published, never 0; the status says why and since when.
-
"No predicted departure" is published only for a stop where 511 has shown a departure once: a mistyped stop code would otherwise look like an empty stop.
-
A stop that 511 answers 404 (unknown) is tried again after 30 minutes; the other stops go on.
-
A refused token (401 to a departures read) stops every read and is kept (a short fingerprint in
/data, never the token): save a new token to read again. A 401 to an alerts read is not taken as a refused token.
Privacy
The token is kept by Gladys in its database, never shown again, sent only to
511.org, never written in the logs, the status nor /data. Your stop codes are
written to /data only as salted fingerprints; the operator ids and the lines
seen at a stop are written in clear (no personal data).
Licence and data
The code is under the Apache License 2.0. The data is provided by 511.org (Metropolitan Transportation Commission) under the 511 Data Disseminator Agreement that you accept with your token: data provided by 511.org, no warranty, no operator logo. The integration does not use "511" as a brand.
Konfigurationseinstellungen
Diese Einstellungen fragt SF Bay Area Transit in seinem Konfigurationsbildschirm in Gladys ab.
| Einstellung | Typ | Pflichtfeld | Beschreibung |
|---|---|---|---|
| SF Bay Area transit departures and alerts | section | Nein | The next departures and the service alerts at up to five stops of the San Francisco Bay Area (Muni, BART, Caltrain, AC Transit, SamTrans, VTA, Golden Gate...), data provided by 511.org. You need a free 511 token (511.org/open-data/token, by e-mail). A token allows 60 requests per hour by default: the integration plans its reads to stay within 90 % of the limit you give, one request per stop and per read, the alerts one request per operator every 15 minutes or more. Each stop is a device. Check 511.org or the operator before you travel: this integration is not an official source and is not endorsed by 511 or MTC. |
| 511 token | secret | Ja | Your 511 Open Data token (the api_key of the e-mail from 511). Kept by Gladys in its database, never shown again, sent only to 511.org. |
| Language of the texts | select | Nein | Language of the device names, the departure texts and the status. The alerts come in this language when the operator gives it, else in English. |
| Read interval of the departures (minutes) | number | Nein | From 2 to 60 minutes. One request per stop at each read. Lengthened automatically when the stops and the alerts would not fit in the hourly limit (the status says so). |
| Hourly limit of your token | number | Nein | Requests per hour allowed to your token: 60 unless 511 raised it for you (20 to 1000). The integration never sends more than 90 % of it in any hour. |
| Service alerts | select | Nein | Read the service alerts of the operators of your stops (one request per operator every 15 minutes or more). |
| Stop 1 | section | Nein | Required. An operator id and a stop code of 511. The stop code is on the sign of the stop or in the stop list of the operator on 511.org (e.g. SF 15553 for Muni, BA for BART, CT for Caltrain, AC for AC Transit). |
| Name | string | Nein | Name of the device in Gladys (60 characters at most). Empty: the operator and the stop code. |
| Operator id | string | Ja | The 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)... |
| Stop code | string | Ja | The stop code of 511 (letters, digits, - and _); a parent station gives every platform. |
| Lines (optional) | string | Nein | Only these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line. |
| Stop 2 | section | Nein | Optional. An operator id and a stop code of 511. The stop code is on the sign of the stop or in the stop list of the operator on 511.org (e.g. SF 15553 for Muni, BA for BART, CT for Caltrain, AC for AC Transit). |
| Name | string | Nein | Name of the device in Gladys (60 characters at most). Empty: the operator and the stop code. |
| Operator id | string | Nein | The 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)... |
| Stop code | string | Nein | The stop code of 511 (letters, digits, - and _); a parent station gives every platform. |
| Lines (optional) | string | Nein | Only these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line. |
| Stop 3 | section | Nein | Optional. An operator id and a stop code of 511. The stop code is on the sign of the stop or in the stop list of the operator on 511.org (e.g. SF 15553 for Muni, BA for BART, CT for Caltrain, AC for AC Transit). |
| Name | string | Nein | Name of the device in Gladys (60 characters at most). Empty: the operator and the stop code. |
| Operator id | string | Nein | The 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)... |
| Stop code | string | Nein | The stop code of 511 (letters, digits, - and _); a parent station gives every platform. |
| Lines (optional) | string | Nein | Only these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line. |
| Stop 4 | section | Nein | Optional. An operator id and a stop code of 511. The stop code is on the sign of the stop or in the stop list of the operator on 511.org (e.g. SF 15553 for Muni, BA for BART, CT for Caltrain, AC for AC Transit). |
| Name | string | Nein | Name of the device in Gladys (60 characters at most). Empty: the operator and the stop code. |
| Operator id | string | Nein | The 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)... |
| Stop code | string | Nein | The stop code of 511 (letters, digits, - and _); a parent station gives every platform. |
| Lines (optional) | string | Nein | Only these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line. |
| Stop 5 | section | Nein | Optional. An operator id and a stop code of 511. The stop code is on the sign of the stop or in the stop list of the operator on 511.org (e.g. SF 15553 for Muni, BA for BART, CT for Caltrain, AC for AC Transit). |
| Name | string | Nein | Name of the device in Gladys (60 characters at most). Empty: the operator and the stop code. |
| Operator id | string | Nein | The 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)... |
| Stop code | string | Nein | The stop code of 511 (letters, digits, - and _); a parent station gives every platform. |
| Lines (optional) | string | Nein | Only these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line. |
So installierst du SF Bay Area Transit in Gladys
- Öffne in Gladys Integrationen: SF Bay Area Transit erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
- Klicke auf Installieren. Gladys lädt das Docker-Image (
ghcr.io/lm1lc3n7/gladys-sf-bay-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). - Öffne den Bildschirm Konfiguration der Integration, fülle die Einstellungen aus und speichere.
- Du kannst sie auch direkt über die URL ihres Repositorys installieren: https://github.com/LM1LC3N7/gladys-sf-bay-transit.
SF Bay Area 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
SF Bay Area 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.
- Alle Integrationen durchsuchen, native und aus der Community
- Deine eigene externe Integration bauen und veröffentlichen
- Quellcode auf GitHub — Quelle dieser Dokumentation