Skip to main content

HSL Helsinki smart home integration, free and open source

HSL Helsinki integration for Gladys Assistant

Helsinki region public transport (HSL) and Finland: real-time departures, delays and disruptions.

Overview​

This integration brings the public transport of the Helsinki region (HSL) into Gladys: metro, trams, buses, commuter trains and ferries of Helsinki, Espoo, Vantaa and the neighbouring towns. Through the other Digitransit regions, it also works in the Waltti cities (Tampere, Turku, Oulu, Jyväskylä, Kuopio, Lahti…), in the whole of Finland and Estonia, and in Southwest Finland.

It gives the next departures in real time at the stops you choose (three in the form, up to 7 more with a button), filtered by line and direction, with their delay and the cancelled trips, and the traffic of the lines you follow: normal service, information, disrupted, heavily disrupted, with the disruption messages of HSL and the other operators. Each stop and each line becomes a device to show on a dashboard and to use in scenes.

The data come from the official Digitransit API (run by HSL, Fintraffic and Waltti), which asks for a free subscription key. Data © Digitransit, CC BY 4.0.

All the followed stops are read in one request, every minute by default; the disruptions are read every 5 minutes. The integration pauses 5 minutes if the API says its rate limit is reached. At night, while no stop announces anything in the next 45 minutes, the stops are read every 10 minutes.

A departure is followed in real time when the vehicle sends its position; the integration then knows its delay. Otherwise it is the timetable time, marked "(timetable)" (a star in the widget). A trip cancelled in real time is skipped by the devices and crossed out (✕) in the widget.

This is a cloud integration: it contacts api.digitransit.fi only, with your key and the ids of your stops. Nothing else leaves your network.

This integration was written from the public documentation and the schema of the Digitransit API, without a key of its own: if something looks wrong, a report with the Diagnostic button helps a lot.

Requirements​

  • Gladys Assistant 5.3.0 or later.
  • Internet access from the Gladys server.
  • A Digitransit subscription key, free: create an account on the Digitransit API portal (an email address and a two-factor code), open Products, subscribe to the Developer product (a short questionnaire), then copy the primary key from the Profile tab ("Show"). See how to get a key.

Configuration​

FieldWhat to type
Subscription keyThe primary key of your Digitransit subscription. Never written to the logs.
RegionHSL (Helsinki region, default), Waltti cities, Finland and Estonia, or Southwest Finland.
Language of the dataEnglish (default), Finnish or Swedish: the stop names and the disruption messages, when the operator translates them.
Stop 1, 2, 3The name of the stop ("Kamppi", "Rautatientori": a station takes all its platforms), the code on its sign ("H1234") or its id.
LineOnly this line: "550", "M1", "4", "I", or a mode alone: "metro", "tram", "bus", "train", "ferry". Empty: every line of the stop.
DirectionOnly the destinations holding these words: "Itäkeskus", "Itäkeskus | Vuosaari". Empty: both directions.
Followed linesThe lines whose traffic you follow, separated by commas: "550, M1, 4, I" (up to 10). One device per line.
Follow accessibility issuesCounts the accessibility issues (an elevator out of service…) among the messages of your stops. Off by default.
Reading of the stopsEvery 30 seconds, minute (default), 2 minutes or 5 minutes.
Language of the textsNames of the devices, summaries and outputs of the scenes.

The Find a stop button gives the stops and stations whose name starts with a few words (or that carry a sign code), with their code, platform and id: "Kamppi (station) [HSL:1000201]", "Ooppera (H0113) [HSL:1130446]". A station (a metro or train station) takes every platform; a name carried by two stops (both sides of a street) follows both. To keep one stop, type its code or its id. Test the connection checks the key, finds each followed stop, reads its departures and the disruptions right away, and says what answered.

More stops than the three of the form (home, work, school…): Add a stop takes the same three fields — stop, line, direction — and follows up to 7 more stops. List the stops shows every followed stop, numbered; Remove a stop takes that number (or the name). The added stops are kept in the configuration of Gladys, so they follow its backups.

Usage​

Devices​

In the Discover tab, create the devices you want:

  • HSL <stop>: the next departure as text ("M1 → Vuosaari · 3 min", "(+4 min)" when it runs at least 2 minutes late), the wait of the next departure and of the one after (minutes), the delay of the next departure (minutes, 0 when on time) and the number of disruption messages under way about the stop. A cancelled trip is skipped. At night, without any departure, the waits keep their last value.
  • HSL metro M1, HSL tram 4, HSL bus 550: the traffic of the line as text ("Disrupted: Bus 550, diversion route") and its number of messages under way.

Outside the Helsinki region, the devices are called Digitransit <stop>.

Traffic of the lines and stops​

HSL and the other operators publish their disruptions in the Digitransit API, with a severity and an effect:

  • a disruption of one or more lines, or of the whole network: the line is disrupted (a diversion, delays, a reduced service), heavily disrupted when it does not run or the alert is severe;
  • a stop notice, about some stops only (a stop moved or not served): it counts for those stops, and as information for the line;
  • an accessibility issue (an elevator out of service), only when Follow accessibility issues is on: an information, the service stays normal.

A line device shows the heaviest message under way. A stop device counts the disruptions of the lines calling there (as filtered by line and direction) and the notices of its own platforms. The messages come in the language of the data when the operator translates them, in Finnish otherwise.

Dashboard widgets​

The HSL departures widget at Kamppi and the traffic widget (generated illustration, not a screenshot)

  • Departures: the next departures of a stop, compact. One row per line and destination, with its next departures in a row ("3 · 9 min"); a star marks a time of the timetable only, a cross a cancelled trip. The Routes shown setting sets the number of rows. Choose a followed stop, or type any stop (and a line) in the widget settings: such a stop costs one more request at each refresh, every minute at most. With Several stops, one widget shows several stop devices.
  • HSL traffic: the state of the followed lines (or of the lines typed in the settings; the lines of the followed stops, or the metro, when none is followed), then their messages under way and coming. Tap a card for the full text.

Scenes​

Triggers, once per change (the first reading is only a baseline):

  • HSL: departure soon: a vehicle at a followed stop leaves in 2, 3, 5, 10, 15 or 20 minutes.
  • HSL: departure cancelled: a trip from a followed stop leaving in the next 90 minutes is cancelled.
  • HSL: line disrupted: a followed line becomes disrupted or heavily disrupted.
  • HSL: back to normal: a followed line that was disrupted is back to normal.
  • HSL: new traffic message: a new message about a followed line or stop; filter by kind (disruption, stop notice, accessibility). A disruption whose text changes fires again.

Each gives a ready-made sentence, {{triggerEvent.data.summary}}, and its values (line, destination, time, delay, title, text…). The actions HSL: next departures and HSL: traffic of a line return the same kind of values, to put in a message or to test in a condition.

Examples:

  • When the M1 towards Vuosaari leaves Kamppi in 5 minutes → turn the hall lamp green.
  • When your 7:42 bus is cancelled → send the summary to your phone.
  • Every weekday at 7:30 → read the next departures of your stop and have the kitchen speaker announce them, with the delay.

Transport​

Cloud only: the data come from the internet. Only the stops you follow are asked to the API, in one request, and the disruptions of the region every 5 minutes. A stop or a line you type is looked up once and kept: a restart asks nothing more.

Troubleshooting​

  • "Fill in your Digitransit subscription key": no key yet; see Requirements.
  • "Digitransit refuses the subscription key": the key is wrong or its subscription was cancelled; copy it again from the Profile tab of the portal, and check the subscription to the Developer product.
  • "The Digitransit API asks to slow down": the API answered that its rate limit is reached; the readings resume after 5 minutes. Choose a longer interval.
  • "The Digitransit API does not answer": the server is out of reach or under maintenance; the last readings stay and the integration tries again at the next interval.
  • "Unknown or ambiguous": use Find a stop, then copy the exact name, the code or the id. Check the Region: a Tampere stop is not in the HSL region.
  • "(timetable)" after a departure: no real-time forecast for that vehicle; the time is the one of the timetable and no delay is known.
  • No departure: the integration asks the next two hours; at night the stops are read every 10 minutes.
  • To report a problem: press Diagnostic (the key is never written), then copy the lines starting with "HSL Helsinki diagnostic" from the Logs tab into a GitHub issue or a reply on the forum, with the versions of Gladys and of the integration.

Configuration settings​

These are the settings HSL Helsinki asks for in its configuration screen in Gladys.

SettingTypeRequiredDescription
Digitransit API keysectionNoThe departures, delays, cancellations and disruptions come from the official Digitransit API (HSL, Fintraffic, Waltti), in real time. It asks for a free subscription key: create an account on the Digitransit API portal, subscribe to the "Developer" product (a short questionnaire), then copy the primary key from the Profile tab ("Show"). Data © Digitransit, CC BY 4.0.
Subscription keysecretYesThe primary key of your Digitransit subscription. Never written to the logs.
RegionselectNoThe Digitransit region of your stops. HSL: Helsinki, Espoo, Vantaa and the region. Waltti: Tampere, Turku, Oulu, Jyväskylä, Kuopio, Lahti and the other Waltti cities. Finland: the whole country and Estonia (long-distance trains and coaches too).
Language of the dataselectNoLanguage of the stop names and the disruption messages, when the operator translates them (otherwise Finnish).
Stop 1sectionNoThe stop where you board: its next departures are read in real time. Type its name ("Kamppi", "Rautatientori": a station takes all its platforms), the code on its sign ("H1234") or its id given by the "Find a stop" button ("HSL:1040129"). The line keeps only its departures ("550", "M1", "4", "I", or "metro", "tram", "bus", "train", "ferry" for a whole mode). The direction keeps only the destinations holding these words ("Itäkeskus", "Itäkeskus | Vuosaari").
StopstringNo
LinestringNoEmpty for every line.
DirectionstringNoWords of the destination. Empty for both directions.
Stop 2sectionNo
StopstringNo
LinestringNoEmpty for every line.
DirectionstringNoWords of the destination. Empty for both directions.
Stop 3sectionNoMore stops (home, work, school…): the "Add a stop" button, under the form, follows up to 7 more, "List the stops" shows them all, numbered, and "Remove a stop" stops following one. All the stops are read in a single request.
StopstringNo
LinestringNoEmpty for every line.
DirectionstringNoWords of the destination. Empty for both directions.
Traffic of the linessectionNoThe lines whose traffic you follow: a device per line, with its state (normal service, information, disrupted, heavily disrupted) worked out from the disruption messages of HSL and the other operators, read every 5 minutes.
Followed linesstringNoUp to 10, separated by commas.
Follow accessibility issuesbooleanNoCounts the accessibility issues (an elevator out of service…) among the messages of your stops. Off by default.
OptionssectionNo
Reading of the stopsselectNoHow often the departures of the stops are read: one request for all the followed stops. While no stop announces anything in the next 45 minutes (the night), every 10 minutes. The disruptions are read every 5 minutes.
Language of the textsselectNoNames of the devices, summaries and outputs of the scenes. Automatic: the language of your dashboard, once a widget of the integration has been shown. The names of the stops and the disruption messages follow the language of the data.

How to install HSL Helsinki in Gladys​

  1. In Gladys, open Integrations: HSL Helsinki appears in the catalog, next to the native integrations, with a community badge.
  2. Click Install. Gladys pulls the Docker image (ghcr.io/william-de71/gladys-hsl-helsinki:0.1.0), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration).
  3. Open the Configuration screen of the integration, fill in the settings, and save.
  4. You can also install it directly from its repository URL: https://github.com/William-De71/gladys-hsl-helsinki.

HSL Helsinki requires Gladys >=5.3.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.

Not running Gladys yet? It is free and open source: follow the installation guide to get started.

About external integrations​

HSL Helsinki is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by William-De71, not by the Gladys core team.

Subscribe to the Gladys Assistant newsletter

A few emails per month about new releases and project news. Sent by Pierre-Gilles Leymarie, founder of the project. Unsubscribe anytime 🙂