Skip to content

feat: add AirQualityInput plugin with multi-connector pattern (AQICN, PMS5003, BME680)#2437

Open
Wanbogang wants to merge 2 commits intoOpenMind:mainfrom
Wanbogang:feature/air-quality-input
Open

feat: add AirQualityInput plugin with multi-connector pattern (AQICN, PMS5003, BME680)#2437
Wanbogang wants to merge 2 commits intoOpenMind:mainfrom
Wanbogang:feature/air-quality-input

Conversation

@Wanbogang
Copy link
Collaborator

Overview

Adds a generic AirQualityInput plugin that supports multiple air quality sensors and APIs via a connector pattern. This allows OM1 to read real-time air quality data without changing the core plugin when switching sensors. #365

Features

  • AirQualityInput plugin — reads standardized AirQualityData and converts it to human-readable text for the LLM
  • Connector pattern — swap sensors via config, no code changes needed
  • 3 connectors out of the box:
    • aqicn — AQICN World Air Quality Index cloud API (no hardware needed)
    • pms5003 — PMS5003/PMS7003 particulate matter sensor via Serial/UART
    • bme680 — BME680 environmental sensor (temperature, humidity, VOC) via I2C
  • AQI alerts — WARNING and DANGER thresholds configurable per deployment
  • Async & non-blocking — serial/I2C reads run in executor to avoid blocking event loop

Sensors Integrated

Connector Sensor Interface Data
aqicn AQICN API HTTP AQI, PM2.5, PM10, CO, NO2, SO2, O3, temp, humidity
pms5003 PMS5003/PMS7003 Serial/UART PM2.5, PM10, AQI
bme680 BME680 I2C Temperature, humidity, IAQ score

Configuration Example

# AQICN (cloud, no hardware)
connector: aqicn
connector_config:
  api_key: "your_token_here"
  latitude: -6.9667
  longitude: 110.4167

# PMS5003 (hardware)
connector: pms5003
connector_config:
  port: /dev/ttyUSB0
  location: Outdoor

# BME680 (hardware)
connector: bme680
connector_config:
  i2c_address: 0x76
  location: Indoor
  gas_baseline: 50000.0

- Add AirQualityInput plugin supporting multiple sensors/APIs
- Add connector/base.py: AirQualityData dataclass, AirQualityConnector ABC, get_aqi_level()
- Add connector/aqicn.py: AQICN cloud API connector (no hardware needed)
- Add connector/pms5003.py: PMS5003/PMS7003 particulate sensor via Serial
- Add connector/bme680.py: BME680 environmental sensor via I2C
- Add 88 tests covering all connectors and plugin behavior (100% coverage)
- Patch inputs/__init__.py auto-discovery to support subpackage plugins
- Fix aqi_label/aqi_description unbound variable in _raw_to_text
@Wanbogang Wanbogang requested review from a team as code owners March 3, 2026 13:36
@github-actions github-actions bot added robotics Robotics code changes python Python code tests Test files labels Mar 3, 2026
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

- Fix test_base.py: add type: ignore[abstract] for abstract instantiation
- Fix test_bme680.py: assert aqi is not None before comparison
- Add tests for subpackage scanning in inputs/__init__.py (100% coverage)
- Add tests for load_input error paths (ImportError, AttributeError)
- Move inline 'import types' to top-level in test_init.py
- Use setattr() for ModuleType attribute assignment (pyright)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant