Saltar al contenido principal

Integración domótica SF Bay Area Transit, gratuita y de código abierto

Integración SF Bay Area Transit para Gladys Assistant

Unofficial. Next departures and alerts at your SF Bay Area stops, data provided by 511.org.

info

La documentación de esta integración la escribe su autor y, por ahora, solo está disponible en inglés.

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​

  1. 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.

  2. Find your stop. You need the 511 id of the operator and the stop code:

    OperatorId
    Muni (SFMTA)SF
    BARTBA
    CaltrainCT
    AC TransitAC
    SamTransSM
    VTASC
    Golden GateGG

    The 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.

  3. Install the integration from the catalog, paste the token in 511 token, type the operator and the stop code in Stop 1, and save.

  4. 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 /data before the request leaves, so a restart knows it. When /data cannot 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 /data before 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); , scheduled when 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), or No 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.

Parámetros de configuración​

Estos son los parámetros que SF Bay Area Transit te pide en su pantalla de configuración en Gladys.

ParámetroTipoObligatorioDescripción
SF Bay Area transit departures and alertssectionNoThe 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 tokensecretSí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 textsselectNoLanguage 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)numberNoFrom 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 tokennumberNoRequests 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 alertsselectNoRead the service alerts of the operators of your stops (one request per operator every 15 minutes or more).
Stop 1sectionNoRequired. 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).
NamestringNoName of the device in Gladys (60 characters at most). Empty: the operator and the stop code.
Operator idstringSíThe 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)...
Stop codestringSíThe stop code of 511 (letters, digits, - and _); a parent station gives every platform.
Lines (optional)stringNoOnly these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line.
Stop 2sectionNoOptional. 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).
NamestringNoName of the device in Gladys (60 characters at most). Empty: the operator and the stop code.
Operator idstringNoThe 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)...
Stop codestringNoThe stop code of 511 (letters, digits, - and _); a parent station gives every platform.
Lines (optional)stringNoOnly these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line.
Stop 3sectionNoOptional. 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).
NamestringNoName of the device in Gladys (60 characters at most). Empty: the operator and the stop code.
Operator idstringNoThe 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)...
Stop codestringNoThe stop code of 511 (letters, digits, - and _); a parent station gives every platform.
Lines (optional)stringNoOnly these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line.
Stop 4sectionNoOptional. 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).
NamestringNoName of the device in Gladys (60 characters at most). Empty: the operator and the stop code.
Operator idstringNoThe 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)...
Stop codestringNoThe stop code of 511 (letters, digits, - and _); a parent station gives every platform.
Lines (optional)stringNoOnly these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line.
Stop 5sectionNoOptional. 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).
NamestringNoName of the device in Gladys (60 characters at most). Empty: the operator and the stop code.
Operator idstringNoThe 511 id of the operator: SF (Muni), BA (BART), CT (Caltrain), AC (AC Transit), SM (SamTrans), SC (VTA), GG (Golden Gate)...
Stop codestringNoThe stop code of 511 (letters, digits, - and _); a parent station gives every platform.
Lines (optional)stringNoOnly these lines, comma separated (10 at most), as 511 names them (e.g. 14, 14R). Empty: every line.

Cómo instalar SF Bay Area Transit en Gladys​

  1. En Gladys, abre Integraciones: SF Bay Area Transit aparece en el catálogo junto a las integraciones nativas, con una insignia de comunidad.
  2. Haz clic en Instalar. Gladys descarga la imagen Docker (ghcr.io/lm1lc3n7/gladys-sf-bay-transit:0.1.1), la ejecuta en un entorno aislado del núcleo y genera la interfaz de la integración (dispositivos, descubrimiento y configuración).
  3. Abre la pantalla de Configuración de la integración, rellena los parámetros y guarda.
  4. También puedes instalarla directamente desde la URL de su repositorio: https://github.com/LM1LC3N7/gladys-sf-bay-transit.

SF Bay Area Transit requiere Gladys >=5.3.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​

SF Bay Area Transit 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 LM1LC3N7, no el equipo principal de Gladys.

Suscríbete a la newsletter de Gladys Assistant

Unos pocos correos al mes sobre nuevas versiones y novedades del proyecto. Enviados por Pierre-Gilles Leymarie, fundador del proyecto. Puedes darte de baja cuando quieras 🙂