Saltar al contenido principal

Integración domótica MBTA Boston, gratuita y de código abierto

Integración MBTA Boston para Gladys Assistant

Unofficial. Next MBTA departures and service alerts at your stops (Boston).

info

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

The next departures (subway, light rail, bus, commuter rail, ferry) and the service alerts at up to five stops of the MBTA (Boston area), in Gladys.

This integration is unofficial: it is not affiliated with the MBTA nor MassDOT, and it is not an official source. Check mbta.com or the stop signs before you travel. It has never been tested on a real Gladys installation by its author; it was checked against the live MBTA API.

Get started in 3 steps​

No account and no key: there is nothing to create.

  1. Find the id of your stop. Open the stop on mbta.com: the id is the end of the address of its page. mbta.com/stops/place-pktrm is Park Street (a station: all its platforms), mbta.com/stops/1 is a bus stop.
  2. Install the integration from the catalog, open its configuration and type the id in Stop 1 → Stop id. Save.
  3. Open the Discover tab and press Add on the stop. Its name is the MBTA name of the stop (e.g. "MBTA – Park Street") once the integration has checked it, or the name you typed.

One device per stop. A device belongs to a slot and to its stop. If you type another stop in a slot, the integration offers a new device in the Discover tab: the device of the old stop 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 or the direction keeps the device.

The message at the top of the configuration page tells where each stop stands, e.g. "MBTA – Park Street: next in 4 min (Red Line), 9 departure(s) within 60 min, read Oct 30, 08:05 ET; 0 alert(s), read Oct 30, 08:05 ET." The read times come from the MBTA server; the next read and the end of a pause from the clock of the machine that runs Gladys. The Show the last read button shows the same message; it never reads the MBTA itself.

Choosing what you see​

FieldExampleMeaning
Stop idplace-pktrma station: every platform
Stop id70075one platform (here Park Street, Red Line southbound)
Only these routesRedthe Red Line only
Only these routes1, 47buses 1 and 47 (route id or number shown on the bus)
Direction0 or 10: outbound, south or west; 1: inbound, north or east

Each route of the filter must call at the stop: the integration checks it with the MBTA once, and a route that does not call there is refused (the status names it), so that an unknown stop or route is not shown as "no departure".

What each device holds​

  • Next departure and Following departure: texts with the route, the destination, the minutes to wait (counted against the time of the MBTA server) and the departure time, e.g. Red Line → Ashmont in 4 min (08:09). When there is none, they say so with the time of the read: No predicted departure (read 08:05), No following departure (read 08:05). They are texts so that a departure that no longer exists is never left on the dashboard as a number: Gladys cannot clear a number.
  • Predicted departures (60 min): how many departures the MBTA predicts at the stop within the next hour.
  • Departures: a summary that starts with the time of the read, e.g. 08:05 · Red Line → Ashmont 4, 11 min · Red Line → Alewife 6 min.
  • Alerts in effect: how many MBTA alerts are in effect now for the stop (and its routes and direction when you filtered them).
  • Alert: the text of the most severe one, e.g. "Shuttle buses replace Red Line service… (1 more alert)", or "No alert".

Stop names and alert texts come in English, the only language of the MBTA API. The device names and the summary follow the language you choose.

What the numbers are, and are not​

  • The departures are the MBTA real-time predictions. A trip the MBTA does not track yet is not counted: a bus that has not left its terminal, a commuter rail train far ahead. "No predicted departure" does not mean "no service"; at night it often means the service has ended.
  • When no departure is predicted, the counter shows 0 and the three texts say so. Every read publishes every value again.
  • When a read fails, nothing is published: the values of the last good read stay in Gladys. Each text carries its time (the departure time, or the read time), and the configuration page says the data is stale after 3 intervals (5 minutes at least).
  • A stop is counted at 0 only when the MBTA has confirmed the stop (and the routes of the filter). Until then an empty answer publishes nothing.
  • Nothing is published (no 0, no old value sent again) when a read fails, when the answer cannot be read, when it carries no usable server time, when that time differs by more than 5 minutes from the clock of the machine (a wrong clock, or an old copy served by a cache), or when the MBTA data behind it is more than 10 minutes old (a frozen real-time feed). The configuration page then says so, with the time of the last good data.

Scenes​

Trigger "MBTA departure approaching": a predicted departure at a watched stop gets to 1, 2, 3, 5, 10 or 15 minutes or less (you choose), between two reads: it was further at the read before. A departure that appears already that close (the first read after a start, a bus that just left its terminal) is not announced. Example: "when a bus of stop 1 is 5 minutes away, turn the hall light on". The scene gets the minutes, the route, the destination and the departure time.

Trigger "New MBTA alert at a stop": an alert in effect appears at a watched stop for the first time, and it was created, updated or started within the last 2 hours. Filter on the stop (required), the effect (delay, shuttle, suspension, detour, stop or station closed…) and the severity (severe 7 to 10, moderate 4 to 6, minor 0 to 3). The first read of a stop only learns the alerts already there. The scene gets the alert text, its effect, severity, cause, timeframe and link.

The counters work in the usual scenes of Gladys too, e.g. "if the predicted departures of the stop are 0, send me a message".

Pace and courtesy toward the MBTA​

The MBTA allows 20 requests per minute without a key. The integration sends one request at a time, 3 seconds apart at least:

  • the departures of every stop in one request, at the interval you choose (60 seconds by default, 30 to 600);
  • the alerts every 5 minutes, one request per stop;
  • the check of the stops (name, routes) once, then again 30 minutes later for a stop or a route the MBTA did not know (1 minute after a failed check, doubled each time, 30 minutes at most).

When the MBTA says its limit is near, the next request waits for the end of the minute. A "429" (too many requests) pauses every read for 2 minutes, doubled each time, or until the MBTA limit resets when that is later; a server error on the departures pauses the reads too (1 minute, doubled each time). A pause lasts 6 hours at most. The pause is kept across a restart, and a restart waits for the interval after the last read (30 seconds after the start when /data cannot tell when that was). A failure of the alerts or of the stop check, other than a 429, never holds the departures, and a failed stop check never holds the alerts.

Troubleshooting​

MessageWhat to do
"the MBTA does not know this stop id"Check the id at the end of the stop page on mbta.com.
"a route of the filter does not call at this stop"Fix or remove the route named in the message (use the route id or the bus number).
"the stop could not be checked yet"The MBTA was not reachable for the check; it is tried again, the departures are read anyway.
"differs from the clock of this machine"Set the clock of the machine running Gladys (automatic time); the reads resume by themselves.
"Not updated any more … delete in Gladys"A slot was given another stop: delete the old device in Gladys.
"frozen feed"The MBTA real-time data is not updated; nothing is published until it is.
"MBTA asked to slow down (429)"Another program on your network may use the MBTA API too; the reads resume by themselves.
A stop stays at "No predicted departure"Normal at night, or for a route whose next trip is not tracked yet.

Privacy, data and licences​

  • No account, no key, no location: only the stop ids you type are sent to the MBTA, in the address of the requests.
  • Data: MassDOT / MBTA (api-v3.mbta.com), used under the MassDOT Developers License Agreement. MassDOT makes no warranty on the data, nor does this integration.
  • Integration code: Apache 2.0 licence.

Parámetros de configuración​

Estos son los parámetros que MBTA Boston te pide en su pantalla de configuración en Gladys.

ParámetroTipoObligatorioDescripción
MBTA departures and alertssectionNoThe next departures (subway, light rail, bus, commuter rail, ferry) and the service alerts at up to five stops of the MBTA (Boston area), read from the public MBTA V3 API: no account, no key. Each stop is a device. The departures are the MBTA real-time predictions: a trip that is not tracked yet is not counted. Data: MassDOT / MBTA, in English only, under the MassDOT Developers License Agreement. Check mbta.com before you travel: this integration is not an official source.
Language of the textsselectNoLanguage of the device names and of the departure summary (MBTA stop names and alerts stay in English).
Read interval of the departures (seconds)numberNoFrom 30 to 600 seconds. One request reads the departures of every stop; the alerts are read every 5 minutes. The MBTA allows 20 requests per minute without a key.
Stop 1sectionNoA stop or a station of the MBTA. Its id is at the end of its page on mbta.com: mbta.com/stops/place-pktrm is Park Street (a station: every platform), mbta.com/stops/1 a bus stop. Required.
NamestringNoName of the device in Gladys (60 characters at most). Empty: the MBTA name of the stop.
Stop idstringSíThe id of the stop or station on mbta.com (letters, digits, - and _).
Only these routesstringNoOptional: route ids or bus numbers, separated by commas ("Red", "Green-B", "1, 47", "CR-Worcester"). Each one must call at the stop. Empty: every route of the stop.
DirectionselectNoThe MBTA numbers the two directions of a route 0 and 1.
Stop 2 (optional)sectionNoA stop or a station of the MBTA. Its id is at the end of its page on mbta.com: mbta.com/stops/place-pktrm is Park Street (a station: every platform), mbta.com/stops/1 a bus stop. Leave the id empty to turn it off.
NamestringNoName of the device in Gladys (60 characters at most). Empty: the MBTA name of the stop.
Stop idstringNoThe id of the stop or station on mbta.com (letters, digits, - and _).
Only these routesstringNoOptional: route ids or bus numbers, separated by commas ("Red", "Green-B", "1, 47", "CR-Worcester"). Each one must call at the stop. Empty: every route of the stop.
DirectionselectNoThe MBTA numbers the two directions of a route 0 and 1.
Stop 3 (optional)sectionNoA stop or a station of the MBTA. Its id is at the end of its page on mbta.com: mbta.com/stops/place-pktrm is Park Street (a station: every platform), mbta.com/stops/1 a bus stop. Leave the id empty to turn it off.
NamestringNoName of the device in Gladys (60 characters at most). Empty: the MBTA name of the stop.
Stop idstringNoThe id of the stop or station on mbta.com (letters, digits, - and _).
Only these routesstringNoOptional: route ids or bus numbers, separated by commas ("Red", "Green-B", "1, 47", "CR-Worcester"). Each one must call at the stop. Empty: every route of the stop.
DirectionselectNoThe MBTA numbers the two directions of a route 0 and 1.
Stop 4 (optional)sectionNoA stop or a station of the MBTA. Its id is at the end of its page on mbta.com: mbta.com/stops/place-pktrm is Park Street (a station: every platform), mbta.com/stops/1 a bus stop. Leave the id empty to turn it off.
NamestringNoName of the device in Gladys (60 characters at most). Empty: the MBTA name of the stop.
Stop idstringNoThe id of the stop or station on mbta.com (letters, digits, - and _).
Only these routesstringNoOptional: route ids or bus numbers, separated by commas ("Red", "Green-B", "1, 47", "CR-Worcester"). Each one must call at the stop. Empty: every route of the stop.
DirectionselectNoThe MBTA numbers the two directions of a route 0 and 1.
Stop 5 (optional)sectionNoA stop or a station of the MBTA. Its id is at the end of its page on mbta.com: mbta.com/stops/place-pktrm is Park Street (a station: every platform), mbta.com/stops/1 a bus stop. Leave the id empty to turn it off.
NamestringNoName of the device in Gladys (60 characters at most). Empty: the MBTA name of the stop.
Stop idstringNoThe id of the stop or station on mbta.com (letters, digits, - and _).
Only these routesstringNoOptional: route ids or bus numbers, separated by commas ("Red", "Green-B", "1, 47", "CR-Worcester"). Each one must call at the stop. Empty: every route of the stop.
DirectionselectNoThe MBTA numbers the two directions of a route 0 and 1.

Cómo instalar MBTA Boston en Gladys​

  1. En Gladys, abre Integraciones: MBTA Boston 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-mbta: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-mbta.

MBTA Boston requiere Gladys >=5.1.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​

MBTA Boston 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 🙂