chsi / ha-lta

Retrieve Singapore bus arrival timings in Home Assistant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LTA bus arrival timings custom component for Home Assistant 🚌

Home Assistant custom component to retrieve bus timings, using the Datamall API provided by LTA.

What's new (2.0)

  • Multiple bus stops can be configured
  • Buses to track must be specified in configuration

Installation (HACS)

Installation by HACS is recommended if you would like to stay updated with latest releases.

  1. Follow the instructions here and add this repository.

  2. Request for an API key at Datamall. This key is required for Home Assistant to interact with the bus API.

  3. Restart Home Assistant and configure the component in configuration.yaml with the API key and bus stop codes.

Installation (Manual)

  1. 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.

  2. Request for an API key at LTA Datamall. This key is required for Home Assistant to interact with the bus API.

  3. Configure the component in configuration.yaml with the API key and bus stop codes.

Configuration

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'

Usage

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.

Use cases

  • 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

About

Retrieve Singapore bus arrival timings in Home Assistant

License:MIT License


Languages

Language:Python 100.0%