Custom Home Assistant integration for fetching NextBus arrival predictions. This repository mirrors the upstream nextbus
integration so it can be developed and fixed outside of Home Assistant core.
- Fetches live predictions from the NextBus public API
- Simple configuration via the Home Assistant UI
- Optional Lovelace card for displaying upcoming departures
- Built-in request timeouts and error handling for improved reliability
- Automation blueprints for notifications and MQTT publishing
- Fully tested with
pytest
Via HACS
- Make sure HACS is installed and working in your Home Assistant instance.
- In HACS, add this repository as a Custom Repository (integration category).
- Install the NextBus integration from the list.
- Restart Home Assistant.
- Copy the
custom_components/nextbus
folder to<config>/custom_components/nextbus
in your Home Assistant configuration directory. - (Optional) Copy
next-bus-card.js
into<config>/www
and add it as a resource to your dashboard. - Restart Home Assistant.
- Navigate to Settings → Devices & services in Home Assistant.
- Click Add Integration and search for NextBus.
- Enter the agency and stop information when prompted.
- Save to create the entity.
Two blueprints are included to help you automate around bus arrivals:
- Publish NextBus predictions to MQTT – forwards sensor data to an MQTT topic.
- Notify when NextBus is approaching – sends a notification when a bus is within a configurable number of minutes.
Import the blueprints from the blueprints/automation/nextbus
directory into Home Assistant to use them.
After copying next-bus-card.js
into your dashboard resources, create a card using the next-bus-card
type:
type: custom:next-bus-card
entity: sensor.my_bus_stop
Enable debug logging either during configuration or through configuration.yaml
:
logger:
default: info
logs:
custom_components.nextbus: debug
Logs can then be viewed via Settings → System → Logs or the Home Assistant log file.
- Python 3.11+
requests
,pytest
,flake8
,black
./setup.sh
source .venv/bin/activate
pytest
Format code with black
and ensure linting passes with flake8
before committing.
Issues and pull requests are welcome. If proposing a new feature, please open an issue first to discuss your idea.
Distributed under the MIT License. See LICENSE for details.