Provides live bus timings from Transport for London for London buses.
You can install this through HACS.
Otherwise, you can install it manually.
- Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).
- If you do not have a custom_components directory (folder) there, you need to create it.
- In the custom_components directory (folder) create a new folder called tfl_livearrivals.
- Download all the files from the custom_components/tfl_livearrivals/ directory (folder) in this repository.
- Place the files you downloaded in the new directory (folder) you created.
- Inside the new directory, run 'pip install -r requirements.txt'
- Restart Home Assistant
You will configure one integration per bus stop.
You may specify one or more buses to monitor per stop.
Go to the following URL:
https://api.tfl.gov.uk/Line/[buses you want to monitor]/Arrivals
[buses you want to monitor]
is a comma-separated list of buses you are interseted in. For example, the following URL will pull all arrivals for the 2, 68, and 196:
https://api.tfl.gov.uk/Line/2,68,196/Arrivals
Next, search the API response for the name of your specific station (retrieve it from Google Maps or similar). The stop ID you want is the naptanId
associated with the stop. Most stops will have two different naptanId
values, one for each direction of travel. Use the destinationName
field to differentiate between the two.
You can add the integration in the usual way using its config-flow, using your comma-separated list of values and the naptanId
as required.
The following example will create a simple table of bus departures, suitable to add to a Markdown card.
### West Norwood
{% set departures = state_attr('sensor.bus_schedule_490001331w_2_68_196', 'departures') %}
| Bus | Destination | min |
| --- | ----------- | --- |{% for departure in departures -%}{% set minutes = ((as_timestamp(departure.expected_time) - as_timestamp(now())) / 60) | round(0) %}
| **{{ departure.line }}** | {{ departure.destination }} | {% if minutes == 0 %}due {% else %}{{ minutes }} {% endif -%}|
{%- endfor %}