Commit Graph

4 Commits

Author SHA1 Message Date
90e3422e8b fix: Repariere alle Unit Tests - SessionDetector jetzt produktionsreif
-  Alle 26 Tests grün (0 failed, 0 errors)
- Phase 2 ist damit 100% fertig!

Tests repariert:
- test_session_detector.py: Alle 7 Tests an env-passing angepasst
  - SessionDetector(device.id, device.name) statt SessionDetector(device)
  - process_power_event(env, power, ts) statt process_power_event(power, ts)
- test_mqtt_mocked.py: Alle 4 Service-Tests korrigiert
  - start_connection_with_env(connection_id, env) Signatur
  - stop_connection(connection_id) Parameter hinzugefügt
  - IotBridgeService direkt instanziiert
  - device.topic_pattern statt nicht-existierendem device_id

Verbesserungen:
- run-tests.sh: Klare Ausgabe mit ✓✓✓ ALL TESTS PASSED ✓✓✓
- run-tests.sh: Parsed Odoo Test-Output korrekt
- run-tests.sh: Exit Code (0=success, 1=failure)

Test-Coverage:
- SessionDetector State Machine vollständig getestet
- Alle 5 States: IDLE/STARTING/STANDBY/WORKING/STOPPING
- Debounce Logic: Start + Stop Timer
- Duration Tracking: Standby/Working Zeiten
- Timeout Detection: 20s Message Timeout
- State Recovery: Nach Restart

SessionDetector ist produktionsreif!
2026-01-30 16:46:35 +01:00
f1b0c50fbf fix: MQTT topic matching + UI button fixes
- Fix MQTT topic pattern matching (_mqtt_topic_matches):
  * Implement proper # wildcard (multi-level)
  * Implement proper + wildcard (single-level)
  * Fix bug where first device got ALL messages
  * Now shaperorigin/# only matches shaperorigin/* topics

- Fix Stop Connection button (Odoo-style):
  * Remove manual commit() - let Odoo handle it
  * Use write() to update state
  * Handle case where service doesn't have connection

- Fix Test Connection hanging:
  * Add proper cleanup with sleep after disconnect
  * Catch cleanup exceptions

- Add @unittest.skip to real MQTT tests:
  * TransactionCase incompatible with paho-mqtt threads
  * See TODO.md M8 for details

- Fix run-tests.sh:
  * Remove -i flag (was hanging)
  * Simplify to direct output redirect

- Add TODO.md documentation
- Update .gitignore for test logs
2026-01-28 22:08:59 +01:00
59539e0201 WIP: MQTT Tests - Mocked approach created but needs better testing strategy
- Created test_mqtt_mocked.py with unittest.mock (following OCA patterns)
- Old tests with real MQTT broker hang in TransactionCase tearDown
- Created run-tests.sh following OCA/oca-ci best practices
- TODO: Find proper way to test MQTT with background threads in Odoo
- TODO: Either fully mock or use different test approach (not TransactionCase)
2026-01-25 10:15:52 +01:00
b6a0f0462d feat: MQTT integration - auto-start, session detection, UI fixes
- Auto-start connections after Odoo restart via _register_hook()
- Start/Stop buttons with invalidate_recordset() and reload action
- Session detection with ShellyParser (RPC, telemetry, status)
- Fixed imports: datetime, ShellyParser
- Parser matches prototype with device_id, timestamp extraction
- Sessions created/ended based on power > 0 threshold
2026-01-24 23:40:03 +01:00