Commit Graph

2 Commits

Author SHA1 Message Date
aeb8e5660b feat: Add timeout detection and comprehensive test suite
- Implement check_timeouts() for session timeout detection (20s)
- Fix code duplication bug in session_detector.py
- Add periodic timeout check in main loop (every 1s)
- Add 13 unit tests for session detection
- Add 5 integration tests with real MQTT broker
- Document Odoo integration strategy in README
- Remove hardcoded credentials, use env vars
- All 18 tests passing
2026-01-24 11:32:23 +01:00
4c03959437 feat(mqtt): Implement M0-M3 - MQTT IoT Bridge with Session Detection
- M0: MQTT Client with TLS/SSL support
  - Connection to mqtt.majufilo.eu:8883
  - Topic subscription with wildcards
  - JSON payload parsing

- M1: Shelly PM Mini G3 Integration
  - Status message parser (shaperorigin/status/pm1:0)
  - Custom MQTT topic prefix support
  - Power, voltage, current, frequency extraction
  - Device mapping via topic_prefix

- M2: Event Normalization
  - Event Schema v1 with UUID-based event IDs
  - ISO 8601 UTC timestamps
  - Machine/Device info mapping
  - Metrics normalization (power_w, voltage_v, current_a, frequency_hz)
  - Filter None values

- M3: Session Detection Engine
  - State machine: IDLE → STARTING → RUNNING → STOPPING → IDLE
  - Power-based threshold detection (configurable per machine)
  - Debounce logic (separate for start/stop)
  - Session events with duration calculation
  - Persistent storage (JSONL for events, JSON for sessions)
  - Odoo-ready data format for future migration

Data Storage:
- events.jsonl: JSON Lines format (one event per line)
- sessions.json: Session records with start/end/duration
- Ready for migration to open_workshop.session model

Multi-device ready: Add devices via config.yaml with unique topic_prefix
2026-01-22 19:59:17 +01:00