Core modules created:
- config.py: Environment-based configuration management
- Loads MQTT settings from environment variables
- SensorConfig class for JSON sensor mapping
- Relative path resolution (PROJECT_ROOT)
- Configuration validation with fail-fast
- mqtt_publisher.py: MQTT client wrapper
- MQTTPublisher class with connection management
- Replaces sendToMQTT.sh shell script
- Direct Python MQTT publishing
- Automatic reconnection support
- Optional battery data publishing
- sensor_reader.py: Bluetooth BLE sensor reader
- SensorReader class for passive BLE scanning
- ATC firmware packet parsing
- Duplicate packet filtering via advertisement counter
- Watchdog thread for BLE recovery
- Measurement dataclass for type safety
- utils.py: Bluetooth utilities
- Ported from bluetooth_utils.py (MIT, Colin GUYON)
- BLE scanning and advertisement parsing functions
- Linux HCI socket operations
- main.py: Application entry point
- Sensorpajen main application class
- Signal handling (SIGTERM/SIGINT) for graceful shutdown
- Logging to stdout for journald integration
- Coordinates all components
Architecture:
- Direct Python integration (no shell scripts)
- Clean separation of concerns
- Type hints and dataclasses
- Comprehensive logging
- Graceful shutdown handling
Updated ROADMAP.md to mark Phase 2 as complete.
Next: Phase 3 - Configuration Migration (mostly done in Phase 1)
Directory structure:
- Created src/sensorpajen/ for new Python package
- Created config/ for configuration templates
- Created legacy/ for old scripts
- Created systemd/ and debian/ for future phases
Package setup:
- Added pyproject.toml with modern Python packaging
- Created package __init__.py
- Defined dependencies: bluepy, paho-mqtt
Configuration:
- Created config/sensors.json.example (converted from INI)
- Created config/sensorpajen.env.example for environment variables
- All 8 Xiaomi sensors migrated to JSON format
Cleanup:
- Removed temperatur_koksfonstret.py (DHT11 functionality)
- Moved all legacy scripts to legacy/ folder:
- LYWSD03MMC.py
- bluetooth_utils.py
- sendToMQTT.sh
- sensorer.sh
- startup.sh
- sensorer.ini
Updated ROADMAP.md to mark Phase 1 as complete.
Next: Phase 2 - Python Package Structure
- AGENTS.md: Guidelines for AI agents working on this project
- ROADMAP.md: Complete migration plan from tmux/cron to systemd
- Configuration strategy using relative paths
- APT package creation plan (Phase 8)
- Progress tracking instructions