Real-time garbage truck tracking integration for New Taipei City, Taiwan. Automatically trigger Home Assistant automations when trucks approach or pass your collection points.
Track garbage trucks in real-time using the New Taipei City Environmental Protection Bureau API. Get notifications and trigger automations when trucks are near your location.
- ๐ Real-time Tracking: Monitor New Taipei City garbage truck locations
- ๐ Smart Collection Points: Automatic route analysis and collection point suggestions
- ๐ฏ Multi-route Support: Track multiple garbage truck routes simultaneously
- โฐ Early Notification: Configurable advance notification (N stops ahead)
- ๐ Native Integration: Full Home Assistant integration with config flow
- ๐ Automatic Updates: Real-time status updates via coordinator
- ๐จ Binary Sensor: Easy automation with nearby/idle states
Truck approaching entry point โ Binary Sensor: ON โ HA automation โ ๐ก Light ON
Truck passing exit point โ Binary Sensor: OFF โ HA automation โ ๐ Light OFF
-
Add Custom Repository
- Open HACS in Home Assistant
- Click on "Integrations"
- Click the 3-dot menu (top right) โ "Custom repositories"
- Add repository URL:
https://github.com/iml885203/trash_tracking - Category: "Integration"
- Click "Add"
-
Install Integration
- Search for "Trash Tracking" in HACS
- Click "Download"
- Restart Home Assistant
-
Add Integration
- Go to Settings โ Devices & Services
- Click "+ Add Integration"
- Search for "Trash Tracking"
- Follow the setup wizard
-
Download Integration
cd /config mkdir -p custom_components cd custom_components git clone https://github.com/iml885203/trash_tracking.git
-
Copy Files
cp -r trash_tracking/custom_components/trash_tracking ./
-
Restart Home Assistant
-
Add Integration
- Go to Settings โ Devices & Services
- Click "+ Add Integration"
- Search for "Trash Tracking"
- Follow the setup wizard
The integration provides an easy-to-use setup wizard:
-
Enter Your Address
- Input your address in Taiwan format
- Example:
ๆฐๅๅธๆฟๆฉๅๆฐ็่ทฏไบๆฎต80่
-
Select Route
- The wizard will automatically find nearby garbage truck routes
- Routes are sorted by distance from your location
- Select the route that serves your area
-
Configure Collection Points
- Entry Point: Truck status changes to "nearby" when arriving at this point
- Exit Point: Truck status returns to "idle" when passing this point
- Points are automatically suggested based on your location (entry point = nearest point - 1)
After setup, the integration creates:
Binary Sensor:
binary_sensor.trash_tracking_[route_name]_nearby: ON when truck is near
Sensor:
sensor.trash_tracking_[route_name]_info: Detailed truck information
automation:
- alias: "Garbage Truck Approaching - Turn On Light"
trigger:
- platform: state
entity_id: binary_sensor.trash_tracking_c08_afternoon_nearby
to: 'on'
action:
- service: light.turn_on
target:
entity_id: light.notification_bulb
data:
brightness: 255
rgb_color: [255, 0, 0]
- alias: "Garbage Truck Left - Turn Off Light"
trigger:
- platform: state
entity_id: binary_sensor.trash_tracking_c08_afternoon_nearby
to: 'off'
action:
- service: light.turn_off
target:
entity_id: light.notification_bulbautomation:
- alias: "Garbage Truck Notification"
trigger:
- platform: state
entity_id: binary_sensor.trash_tracking_c08_afternoon_nearby
to: 'on'
action:
- service: notify.mobile_app_your_phone
data:
title: "๐ ๅๅพ่ปไพไบ๏ผ"
message: "ๅๅพ่ปๆญฃๅจๆฅ่ฟ๏ผ่ซๆบๅๅๅๅพ"
data:
priority: high
ttl: 0automation:
- alias: "Garbage Truck Audio Announcement"
trigger:
- platform: state
entity_id: binary_sensor.trash_tracking_c08_afternoon_nearby
to: 'on'
action:
- service: tts.google_translate_say
target:
entity_id: media_player.living_room_speaker
data:
message: "ๅๅพ่ปๅณๅฐๅฐ้๏ผ่ซๆบๅๅๅๅพ"automation:
- alias: "Garbage Truck Weekday Notification"
trigger:
- platform: state
entity_id: binary_sensor.trash_tracking_c08_afternoon_nearby
to: 'on'
condition:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- service: light.turn_on
target:
entity_id: light.notification_bulbThe binary sensor provides rich attributes for advanced automations:
binary_sensor.trash_tracking_c08_afternoon_nearby:
state: 'on' # or 'off'
attributes:
current_point: "Minsheng Rd. Sec. 2, No. 80"
current_rank: 12
total_points: 69
distance_meters: 45.2
car_no: "ABC-1234"
line_name: "C08 Afternoon Route"
last_update: "2025-11-23T14:30:00"automation:
- alias: "Announce Current Stop"
trigger:
- platform: state
entity_id: binary_sensor.trash_tracking_c08_afternoon_nearby
to: 'on'
action:
- service: notify.mobile_app_your_phone
data:
message: >
ๅๅพ่ป็ฎๅๅจ๏ผ{{ state_attr('binary_sensor.trash_tracking_c08_afternoon_nearby', 'current_point') }}
่ท้ขๆจ๏ผ{{ state_attr('binary_sensor.trash_tracking_c08_afternoon_nearby', 'distance_meters') }} ๅ
ฌๅฐบFor developers or advanced users, a CLI tool is available for testing:
# Install CLI tool
pip install -e apps/cli/
# Query trucks by coordinates
python -m trash_tracking_cli --lat 25.018269 --lng 121.471703
# Suggest configuration by address
python -m trash_tracking_cli --suggest "ๆฐๅๅธๆฟๆฉๅๆฐ็่ทฏไบๆฎต80่"
# Filter specific route
python -m trash_tracking_cli --lat 25.018269 --lng 121.471703 --line "C08"# Clone repository
git clone https://github.com/iml885203/trash_tracking.git
cd trash_tracking
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install core package in editable mode
pip install -e packages/core/
# Install dev dependencies
pip install -r requirements-dev.txt
# Install pre-commit hooks
pre-commit install# Run all tests
pytest
# Run with coverage
pytest --cov=packages/core/trash_tracking_core --cov-report=html
# Run specific test
pytest tests/test_tracker.py -v# Linting
flake8 packages/core/trash_tracking_core custom_components/trash_tracking
# Format code
black packages/core/trash_tracking_core custom_components/trash_tracking
isort packages/core/trash_tracking_core custom_components/trash_tracking
# Type checking
mypy packages/core/trash_tracking_core --ignore-missing-imports- Architecture Design - Technical architecture overview
- Development Guide - Development setup and guidelines
- API Specification - NTPC API documentation
- Versioning Guide - Release and versioning strategy
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- New Taipei City Environmental Protection Bureau for providing the public API
- Home Assistant community for the amazing platform
- All contributors who helped improve this integration
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: GitHub Wiki
Made with โค๏ธ for the Home Assistant community