{"id":44839680,"url":"https://github.com/hanwg/sg-bus-arrivals","last_synced_at":"2026-05-02T10:03:21.838Z","repository":{"id":290907604,"uuid":"975958529","full_name":"hanwg/sg-bus-arrivals","owner":"hanwg","description":"A home assistant custom integration for bus arrival times in Singapore","archived":false,"fork":false,"pushed_at":"2025-12-28T14:43:15.000Z","size":1191,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-17T07:51:19.292Z","etag":null,"topics":["automation","bus","home-assistant","iot","lta-datamall-api","python","smartnation","transport"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanwg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-01T07:59:00.000Z","updated_at":"2026-01-22T08:16:39.000Z","dependencies_parsed_at":"2026-02-17T03:00:47.880Z","dependency_job_id":null,"html_url":"https://github.com/hanwg/sg-bus-arrivals","commit_stats":null,"previous_names":["hanwg/sg-bus-arrivals"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/hanwg/sg-bus-arrivals","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanwg%2Fsg-bus-arrivals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanwg%2Fsg-bus-arrivals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanwg%2Fsg-bus-arrivals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanwg%2Fsg-bus-arrivals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanwg","download_url":"https://codeload.github.com/hanwg/sg-bus-arrivals/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanwg%2Fsg-bus-arrivals/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32530178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bus","home-assistant","iot","lta-datamall-api","python","smartnation","transport"],"created_at":"2026-02-17T03:00:26.171Z","updated_at":"2026-05-02T10:03:21.820Z","avatar_url":"https://github.com/hanwg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SG Bus Arrivals\n\n![sg bus arrivals logo](images/icon-128x128.png)\n\nA custom integration for [Home Assistant](https://www.home-assistant.io/).\nThis integration uses the [LTA DataMall API](https://datamall.lta.gov.sg/content/datamall/en/dynamic-data.html) to fetch bus arrivals and train service alerts for the Singapore public transport.\n\n## Features\n\n- **Bus Arrival Tracking** - Configure bus stops and bus services to create sensors for displaying bus arrival information.\n- **Train Service Alerts** - Stay informed about train disruptions with dedicated sensors for each train line, offering granular control over which alerts to monitor.\n\n## Installation\n\nYou can install using either of the following methods:\n- HACS installation (easiest)\n- Manual installation\n\nAfter installation is completed, continue with the [Configuration](#configuration) section below.\n\n### HACS installation\n\n[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=hanwg\u0026repository=sg-bus-arrivals\u0026category=integration)\n\n### Manual installation\n\nCopy the `custom_components/sg_bus_arrivals` folder and all of its contents into your Home Assistant's `/config/custom_components` folder.\n\n## Configuration\n\nAdd the integration:\n**Settings** \u003e **Devices \u0026 services** \u003e **ADD INTEGRATION** \u003e **SG Bus Arrivals**\n\n### Required manual input\n\n![configuration](images/configuration.png)\n\n- **API account key**: Used for authenticating with the LTA DataMall API. To get an API account key, you need to [request for LTA DataMall API access](https://datamall.lta.gov.sg/content/datamall/en/request-for-api.html).\n\n- **Scan interval**: The frequency (seconds) to fetch data from the LTA DataMall API. A minimum limit of 20 seconds has been imposed to avoid rate-limiting issues.\n\nUpon successful configuration, you should see a single **LTA DataMall API** entry.\nContinue with the [Add new bus service](#add-new-bus-arrival-sensor) section below to add sensors for bus arrival times.\u003cbr/\u003e\n![config-entry](images/config-entry.png)\n\n## Add new bus service\n\nGo to **Settings** \u003e **Devices \u0026 services** \u003e **SG Bus Arrivals**.\n\nClick on the \"...\" icon on the right of the **LTA DataMall API** entry and select **Add new bus service**.\u003cbr/\u003e\n![add new bus service](images/add-new-bus-service.png)\n\n### Required manual input\n\nYou will first be prompted to specify the bus stop code:\u003cbr/\u003e\n![bus stop code](images/bus-stop-code.png)\n\n- **Bus stop code**: The unique 5-digit bus stop code. Use the [LTA Transport Tools (Bus Services)](https://www.lta.gov.sg/content/ltagov/en/map/bus.html) to search for your bus stops and bus services. You can also find bus stop codes at physical bus stop signs and bus guides at bus stops.\n\nThe integration will then fetch all the available bus services at that bus stop. Next, you will need to specify the bus service number:\u003cbr/\u003e\n![service number](images/service-no.png)\n- **Bus service number**: The bus service number at the bus stop.\n\nAfter adding a bus service, you should be able to see a new subentry:\u003cbr/\u003e\n![subentry](images/subentry.png)\n\n### Subentry details\n\nEach subentry contains services which corresponds to the next bus arrivals:\n![](images/services.png)\n\nSelecting any of the service will display the details of the bus arrival sensors:\n![sensors](images/sensors.png)\n\n🎉 Congratulations! You have successfully added a new service to track bus arrivals. You can add more bus services if you like or read on to explore further.\n\n## Add train service alerts\n\nGo to **Settings** \u003e **Devices \u0026 services** \u003e **SG Bus Arrivals**.\n\nClick on the \"...\" icon on the right of the **LTA DataMall API** entry and select **Add train service alerts**.\nYou should see a new **Train Service Alerts** subentry with a single service.\n\nClick on the service to view all train service alert sensors:\n![train service alerts](images/train-service-alerts.png)\n\nEach train service alert sensor has either of the following states:\n- `Normal` - Train service is operating as usual.\n- `Disrupted` - Train service is delayed or disrupted.\n\n## Use cases\n\nHere are some ways you can use this integration.\n\n### Home Assistant Dashboard\n\nAdd sensors to a dashboard for quick access to bus arrival times.\nThe following is an example from the default dashboard:\u003cbr/\u003e\n![dashboard](images/dashboard.png)\n\n### Home Assistant Companion App (Android) Widget\n\nAdd a widget to your home screen to glance at the next bus arrival:\n1. Add an Home Assistant entity widget to your home screen.\n2. Specify the estimated arrival sensor entity ID. e.g. `sensor.sgbusarrivals_01029_145_next_bus_estimated_arrivals`\n3. Tap on the widget to refresh the sensor display value.\n\n### Automation: Send bus arrival notification when leaving home\n\nThis automation sends a notification with the bus arrivals to your Home Assistant companion mobile app when you leave your home WiFi network.\nThe notification is automatically dismissed after 120 seconds.\n\nautomation.yaml (Replace `your_device` and `your_wifi_ssid` accordingly):\n```yaml\nalias: \"Away: Get bus arrivals\"\ndescription: \"\"\ntriggers:\n  - trigger: state\n    entity_id:\n      - sensor.\u003cyour_device\u003e_wifi_connection\n    id: Away\n    from: \u003cyour_wifi_ssid\u003e\nconditions: []\nactions:\n  - action: notify.mobile_app_\u003cyour_device\u003e\n    metadata: {}\n    data:\n      title: Bus Arrivals\n      message: \u003e-\n        Bus 145: {{ states('sensor.sgbusarrivals_01029_145_next_bus_estimated_arrivals') }}\n      data:\n        tag: bus arrivals\n        channel: Bus arrivals\n        timeout: 120\n        alert_once: true\nmode: single\n```\n\n### Automation: Send notification when there is a train service disruption on EWL\n\nThis automation sends a notification to your Home Assistant companion mobile app when there is a train service disruption on the East-West Line (EWL).\n\nautomation.yaml (Replace `your_device` accordingly):\n```yaml\ndescription: \"Send notification when EWL is disrupted\"\nmode: single\ntriggers:\n  - trigger: state\n    entity_id:\n      - sensor.sgbusarrivals_train_service_alert_ewl\n    to: Disrupted\nconditions: []\nactions:\n  - action: notify.mobile_app_\u003cyour_device\u003e\n    metadata: {}\n    data:\n      message: Train service disruption at EWL\n\n```\n\n## Sensors\n\n### Bus arrival sensors\n\nThe bus arrival sensors are created via the [Add new bus service](#add-new-bus-service) setup. The estimated arrival sensor has the following properties:\n- The sensor shows the **estimated** (as per LTA DataMall API) next bus arrival in minutes.\n- The sensor has a precision of up to **1 minute** (as per LTA DataMall API).\n- A sensor state of `0` indicates that the bus is arriving soon, is already at the bus stop or has just left the bus stop.\n- If there are no more bus arrivals (e.g. last bus already departed), the sensor will show `Unknown`. If there was an error fetching the arrival time, the sensor will show `Unavailable`.\n\n#### Sensor naming and IDs\n\nSensor entity IDs have the following naming convention: `sensor.sgbusarrivals_\u003cbus_stop_code\u003e_\u003cservice_no\u003e_next_bus_\u003carrival\u003e_\u003csensor\u003e`\u003cbr/\u003e\nFor example, for the 1st bus arrival for bus service number 145 at bus stop code 01029, the sensor entity id will be: `sensor.sgbusarrivals_01029_145_next_bus_1_estimated_arrival`\n\nThe available sensors are:\n| Sensor            | Description                                                           |\n|-------------------|-----------------------------------------------------------------------|\n| estimated_arrival | The estimated number of minutes before the bus arrives.               |\n| bus_type          | Bus type: `Single Deck`, `Double Deck` or `Bendy`                     |\n| load              | Bus load: `Seats Available`, `Standing Available`, `Limited Standing` |\n| feature           | Bus feature: `Wheel-chair accessible`                                 |\n\n### Train service alerts sensors\n\nSensor entity IDs have the following naming convention: `sensor.sgbusarrivals_train_service_alert_\u003cline\u003e`\n\n## Actions\n\nThe integration provides the following actions.\n\n#### Action: Refresh bus arrivals\n\nThe `sg_bus_arrivals.refresh_bus_arrivals` action initiates a fetch using the LTA DataMall API to update all bus arrival sensors.\n\nYAML:\n```\naction: sg_bus_arrivals.refresh_bus_arrivals\nmetadata: {}\ndata: {}\n```\n\n## Reconfiguration\n\nThis integration supports reconfiguration, allowing you to make changes to the **API account key** and **Scan interval**. Restart is not required upon successful reconfiguration.\n\n## Removing the integration\n\nDeleting the **LTA DataMall API** configuration entry will remove the integration.\nALL related services and sensors will also be deleted.\n\n## FAQS\n\n### How is the data fetched?\n\n#### Bus arrivals\n\nThe **Scan interval** (default: 20 seconds) is configured during the integration setup.\nThis configures the frequency which the integration will poll from the LTA DataMall APIs to fetch the data.\nFor each bus stop specified, the integration makes a single API call to fetch bus arrival information.\n\nExample 1:\nYou added 3 different bus services operating on the same bus stop - The integration makes **1**\nAPI call every 20 seconds.\n\nExample 2:\nYou added 3 bus services, all of them operating on different bus stops - The integration makes **3** API calls every 20 seconds.\n\n#### Train service alerts\nThe data is fetched at a fixed interval of 10 minutes.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanwg%2Fsg-bus-arrivals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanwg%2Fsg-bus-arrivals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanwg%2Fsg-bus-arrivals/lists"}