🚆 FGC Trains Integration (Spain) - Real-time schedules for your Home Assistant

So, I was working on my main wall panel dashboard, trying to figure out what actually useful info I could display there besides the usual weather and time. Living in Terrassa and commuting to Barcelona daily, I realized I was constantly pulling out my phone to check the FGC app to see when my next train was coming.

That’s when it hit me - why not just have the train schedule right there on the wall panel?

I first tried using Home Assistant’s native GTFS integration, but it turns out it wasn’t compatible with the data format FGC provides. So, like any reasonable person, I decided to spend way more time building a custom integration than I’ll ever save by using it. :sweat_smile:

Full disclosure: I’m not a programmer by trade, so this was built with heavy assistance from AI (Claude, specifically). But hey, it works! And now before leaving home, I can just glance at my wall panel to know exactly when my train is coming.

:camera_flash: What it looks like


The main card shows the next train with a countdown, and changes color based on how much time you have (red = run!, orange = hurry up, green = you’re good). There’s even a little running icon when you need to sprint. The chips below show the next 3 trains.

:rocket: How to install it

Step 1: Add to HACS

  1. Open HACS → Integrations
  2. Click the 3 dots menu → Custom repositories
  3. Add: https://github.com/cmos486/fgc-trains
  4. Category: Integration
  5. Search for “FGC Trains” and install
  6. Restart HA

Step 2: Set it up

Go to Settings → Devices & Services → Add Integration → search “FGC Trains”

Pick your line (S1, S2, whatever), your origin and destination stations, and boom - you’ve got sensors.

Step 3: Make it pretty (optional)

If you want the fancy UI from the screenshots, you’ll need Mushroom Cards from HACS. Otherwise, the sensors work fine on their own.

:nerd_face: Technical bits

  • Uses GTFS data that the integration downloads periodically
  • Works for all FGC lines (S1, S2, S5, S6, S7, etc.)
  • You can set up multiple instances for different routes
  • Station names are already in there, so no need to dig through GTFS files

:link: Links

1 Like