A Home Assistant integration for local transport information
A Home Assistant custom integration that provides comprehensive local transport information using the TfL Unified API and National Rail Darwin API.
- Train Departures: Real-time departure times from your local station
- Filtered Departures: Track trains to specific destinations (e.g., Grove Park to London Charing Cross)
- Train Arrivals: Track incoming trains to your station
- Line Status: Southeastern, Southern, Thameslink line status and disruptions
- Bus Arrivals: Real-time bus arrivals at nearby stops (via TfL API)
- NRCC Messages: National Rail Customer Communication messages
- Darwin API Support: Direct connection to Rail Data Marketplace with automatic Huxley fallback
- Add this repository as a custom repository in HACS:
- Go to HACS → Integrations → ⋮ (menu) → Custom repositories
- Add
https://github.com/McDon22/ha-tfl-local-transport - Category: Integration
- Install "TfL Local Transport"
- Restart Home Assistant
- Configure via the UI
- Copy the
custom_components/tfl_local_transportfolder to your Home Assistantconfig/custom_components/directory - Restart Home Assistant
- Go to Settings > Devices & Services > Add Integration
- Search for "TfL Local Transport" and configure
| Setting | Description |
|---|---|
| Station CRS | Your station's 3-letter CRS code (e.g., GRP for Grove Park) |
| Setting | Description | Default |
|---|---|---|
| Darwin API Key | National Rail API key (highly recommended) | None |
| TfL API Key | TfL API key for bus data | None |
| Destinations | London stations to monitor | CHX, LBG, VIC |
| Lines | Rail lines to monitor for status | Southeastern |
| Num Departures | Number of trains to show | 10 |
| Time Window | How far ahead to look (minutes) | 120 |
National Rail Darwin API (highly recommended):
- Visit https://raildata.org.uk/
- Register for an account
- Subscribe to the "Live Departure Board" API
- Use the Consumer Key as your Darwin API key
TfL API Key (recommended for bus data):
- Visit https://api-portal.tfl.gov.uk/
- Register for an account
- Create an application to get your key
Common stations:
| Station | CRS Code |
|---|---|
| Grove Park | GRP |
| Hither Green | HGR |
| Lee | LEE |
| Lewisham | LEW |
| Blackheath | BKH |
| London Bridge | LBG |
| London Charing Cross | CHX |
| London Cannon Street | CST |
| London Victoria | VIC |
Find your station code at: https://www.nationalrail.co.uk/stations/
sensor.train_departures_{crs}- All departures from your stationsensor.train_departures_{crs}_{dest}- Departures to specific destinations
sensor.train_arrivals_{crs}- All arrivals at your station
sensor.line_status- Current line status for monitored lines
sensor.bus_stop_{stop_id}- Bus arrivals at configured stops
type: markdown
title: Next Trains
content: |
{% set trains = state_attr('sensor.train_departures_grp_chx', 'trains') %}
{% for train in trains[:3] %}
**{{ train.scheduled }}** → Platform {{ train.platform or 'TBC' }}
{% if train.is_cancelled %}🚫 CANCELLED
{% elif train.expected != 'On time' %}⚠️ {{ train.expected }}
{% else %}✅ On time{% endif %}
{% endfor %}This integration uses:
-
Rail Data Marketplace API (with Darwin API key):
- Direct access to National Rail Darwin Live Departure Boards
- Most reliable option
-
Huxley2 Community API (fallback):
- REST JSON proxy for Darwin data
- Used when Darwin API unavailable
-
TfL Unified API:
- Line status information
- Bus arrival times
- Verify your Darwin API key is correct
- Check Home Assistant logs for API errors
- Ensure your station CRS code is valid
- Get API keys for higher limits
- The integration updates every 2 minutes
Feel free to submit issues and pull requests!
MIT License
