CP / Metro de Lisboa smart home integration, free and open source

Lisbon Metro line status and live CP train departures in Gladys.
Follow Lisbon public transport in Gladys: the service status of the four Metro de Lisboa lines and the live departures of CP (Comboios de Portugal) trains at the stations you choose, with their delays and cancellations.
No account and no API key: the integration reads the public status of the Metro and the real-time departures boards published by Infraestruturas de Portugal (IP), the rail network manager, which carry the CP trains. It needs Internet access.
Installation
- In Gladys, open Integrations, then the external integrations store.
- Search for CP / Metro de Lisboa and click Install.
- Wait for the container to start: the integration shows up in the list.
Configuration
Open the Configuration tab of the integration:
- Follow the Metro de Lisboa: creates the Metro de Lisboa device (enabled by default).
- CP stations: the stations to follow, separated by commas (5 at most), as names (
Lisboa-Oriente, Sintra) or 7-digit station ids (9431039). Not sure of the spelling? Use the Search a CP station button: it lists the matching stations with their ids. - Departures window: how far ahead the boards look (120 minutes by default).
- Delay alert from: a train late by at least this many minutes fires the Train delayed scene trigger (5 minutes by default).
- Refresh interval: how often the data is read, in seconds (120 by default, 60 minimum).
Save, then use Test the connection: it tells, for the Metro and for each station, whether the service answers. The devices then show up in the Discovery tab: add them.
Devices
- Metro de Lisboa: for each line (yellow, blue, green, red), a disruption value (0 = normal service, 1 = disrupted) and a status text (the operator's message, in Portuguese), e.g. Blue line – disruption.
- CP station (one per station): Next train in (minutes before the next train leaves, delay included), Next train delay (minutes) and Next train (e.g.
16:53 IC 512 → Lisboa-Apolónia (+11 min)). A cancelled train is never the "next train"; with no train in the window, the text shows—.
Scenes and dashboards
Scene triggers
- Metro line disrupted / Metro line back to normal: filter on the lines; variables: line, line name, operator message.
- Train delayed: a train calling at a followed station is late by at least the configured delay (once per train); filter on the station; variables: station, train number, service, destination, scheduled time, delay.
- Train cancelled: a train expected at a followed station is cancelled (once per train); same filter and variables, without the delay.
Scene actions
- Get a Metro line status: outputs disrupted (yes/no) and the operator message — e.g. send yourself a message before leaving if the blue line is disrupted.
- Get the next CP train: for a station, optionally towards a destination (
Sintra); outputs train found, number, service, destination, scheduled time, minutes before departure, delay, number of cancelled trains and a ready-to-send summary.
Dashboard widget
Lisbon transport shows the next trains of a station (chosen in the widget settings, the first one otherwise) with their delays, the status of the four Metro lines and a Refresh button.
Good to know
- The data comes from the operators' public websites, without any guarantee: an unannounced change on their side can interrupt it until the integration is updated.
- The IP website may refuse requests coming from some networks: the connection test then shows
HTTP 403for the stations. The Metro keeps working.
Help
A question or a problem? Ask on the Gladys community forum or open an issue on the GitHub repository.
Configuration settings
These are the settings CP / Metro de Lisboa asks for in its configuration screen in Gladys.
| Setting | Type | Required | Description |
|---|---|---|---|
| Getting started | section | No | No account needed: the integration reads the public status of the Metro de Lisboa lines and the live departures boards of Infraestruturas de Portugal, which carry the CP trains. Use the "Search a CP station" button to find the name or id of your station. |
| Follow the Metro de Lisboa | boolean | No | Creates a device with the service status of the yellow, blue, green and red lines. |
| CP stations | string | No | Station names or 7-digit ids, separated by commas (5 at most). One device per station. |
| Departures window (min) | number | No | How far ahead the departures boards look, in minutes. |
| Delay alert from (min) | number | No | A train late by at least this many minutes fires the "Train delayed" scene trigger. |
| Refresh interval (s) | number | No | How often the Metro status and the departures are read, in seconds (one minute minimum). |
How to install CP / Metro de Lisboa in Gladys
- In Gladys, open Integrations: CP / Metro de Lisboa appears in the catalog, next to the native integrations, with a community badge.
- Click Install. Gladys pulls the Docker image (
ghcr.io/prohand/gladys-cp-metro-de-lisboa:1.1.0), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration). - Open the Configuration screen of the integration, fill in the settings, and save.
- You can also install it directly from its repository URL: https://github.com/prohand/gladys-cp-metro-de-lisboa.
CP / Metro de Lisboa 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
CP / Metro de Lisboa 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 prohand, not by the Gladys core team.
- Browse all integrations, native and community
- Build and publish your own external integration
- Source code on GitHub — source of this documentation