Home Assistant custom component to retrieve bus timings, using the Datamall API provided by LTA.
- Multiple bus stops can be configured
- Buses to track must be specified in configuration
Installation by HACS is recommended if you would like to stay updated with latest releases.
-
Follow the instructions here and add this repository.
-
Request for an API key at Datamall. This key is required for Home Assistant to interact with the bus API.
-
Restart Home Assistant and configure the component in configuration.yaml with the API key and bus stop codes.
-
Download this repository as a ZIP. Copy the folder
/custom_components/ha-lta
and paste it to the/custom_components/
folder in your Home Assistant directory. If you do not have a custom_components folder, create one. -
Request for an API key at LTA Datamall. This key is required for Home Assistant to interact with the bus API.
-
Configure the component in configuration.yaml with the API key and bus stop codes.
Add the following to your configuration.yaml
file and restart Home Assistant to load the custom component. Bus stop codes are found at all bus stops and are 5 digit numbers such as 97061
and 08138
. At least one bus stop code and one bus is required.
sensor:
- platform: lta
api_key: XXXXXXXXXX
enable_arr_state: True
enable_na_state: True
bus_stops:
- code: 'XXXXX'
buses:
- 'XX'
- 'XXX'
- 'X'
- code: 'XXXXX'
buses:
- 'X'
- 'XX'
After you have setup the configuration with valid bus stop codes and bus numbers, multiple sensor entities will be added for each bus number. Each bus number has 3 subsequent timings. The naming convention for a lta
sensor is as follows:
lta.BUS_STOP_CODE-BUS_NUMBER-BUS_ORDER
For example, sensor lta.98051-19-1
indicates the first timing for bus 19 towards bus stop code 98051. Sensor lta.98051-19-2
will indicate the next subsequent timing for the same bus number.
Some buses only operate on certain timings. Home Assistant will automatically add and remember them when they are in operation.
Most buses provide their present locations and can be viewed on the map.
- Tell the bus timing before leaving the house through a smart speaker
- Setup a dashboard to track timings without opening phone app
- Make use of timing entities for other IOT related projects