Custom Component: London TfL Departures integration

Hey everyone! I was in need of a simple way to see when the next trains from my local London tube / DLR station would leave (to minimise time spent waiting for a train).

None of the integrations I found did what I needed, so here I am having written my own.

It’s not HACS-ready yet, but will be at some point, once I’m happy with how it behaves.

Once dropped into your custom_components, you can add it via the Integrations menu (Search for ‘London TfL’). It automatically populates the lines list and the correct stations based on the line you need, and you can add as many stations as you’re interested in.

It updates once per minute, but doesn’t always hit the public API. It tries to maximise using the data it receives in a single call. Anecdotally it makes a remote call once every 10 minutes, for each sensor.

If you have any issues, please do share! I’ve already fixed quite a few originating from TfL API’s weird choices at times.

1 Like

You can now add it via HACS as a custom component (not yet part of the default set advertised in HACS, but hopefully soon)! With more than a month of testing and actual usage, with a couple of bug fixes thanks to members of the community finding issues, I think it’s pretty stable now.

Hi, I’ve been using this integration and finding it, combined with the lovelace-departures card, very neat.

I can’t for the life of me work out how to add more stations/lines after the initial setup though. I’m sure it must be something obvious but I just can’t spot it. Cheers.

Glad you find it useful!

You can add more stations / lines by just adding the integration again. It’s… not clean, but it works.

Note: only add new stations with the new integrations. Old one will still exist.

Just installed this via HACS and combined with the HASL Departure Card - great integration, thanks!

1 Like

Cant seem to get this to work correctly with the latest HASL Departure Card. The Platform or Bus numbers do not come up.
Any ideas on what I may be missing here? This is what I get the number should show up next to the icon on the left.

image

Yep, this has been raised as an issue on GitHub. I can’t promise a quick solution (super busy next week), but will try as soon as I can.

Hi! This is exactly what i was looking for!! Thank you!

Does this also work for bus departure and arrival times?

It sure does!

1 Like

Legend! Absolute legend!

Thank you so much about this. Really useful. Just installed it via HACS yesterday. One question though: Is it easy to filter for a particular bus number?
When I select a bus stop I seem to get departures from all the bus-lines stopping there and not only the one I selected via the UI.

Yes! You can use the Platform filter to only show a particular bus number.

1 Like

Perfect … thanx. I missed that. Thanx again for this.

1 Like

Love the integration thanks! I see “river-tour” in the list and was hoping this was Thames Clippers, but it doesn’t seem to work (doesn’t have a field to enter any details after I select it).

You’re right. I’ll try to find some time and see if there’s any data about it at all.

I remember adding it to the list of transport methods as it was one I saw as possible on the API, but did not check it.

1 Like

No updates on river-tour. Seems weird on tfl’s list. Might remove it altogether to avoid confusion, for now. Or keep looking.

But news! The newest version 0.8.0 also pulls schedule data for your stop(s) and offers 2 new sensors, one with the scheduled data and one with a mix of realtime plus scheduled, attempting to fuse where sensible.

Would love it if people can stress test that and find bugs.

OK thanks for looking anyway! I’m not sure if I’ve configured it wrong, but I have a departures board for Battersea Power Station and it shows two platforms (correct) and different departure times… but only for a short time after restarting HA. After that, they both show identical data. It seems to happen once a train leaves a platform - it gets replaced with the data from the other line.

That seems weird. I’ll add it to mine as well and investigate over the next few days.

Can confirm, the 2 sync up immediately. However the schedule seems to have an extra, spookier line:

1 Like

Yep, seems to be what TfL is reporting. I did find a niche scenario where the default sensor might have been wrong sometimes, but nothing obvious for Battersea :frowning: