open_workshop/open_workshop_mqtt
matthias.lotz b46fed0f8e feat: SessionDetector Integration - Live-Tracking & Timeout Worker
Integriert SessionDetector vollständig in iot_bridge_service:

iot_bridge_service.py:
- SessionDetector Import & _detectors Dictionary
- Timeout Worker Thread für automatisches Session-Ende
- _restore_detector_states() bei Service-Start
- _get_or_create_detector() Factory Methode
- _process_session() ruft detector.process_power_event(env, power, ts)
- _timeout_worker_loop() prüft alle 10s auf Timeouts

models/mqtt_session.py:
- current_power_w Field für Live-Power Updates
- current_state Field für State Machine Status (idle/starting/standby/working/stopping)
- last_message_time Field für Timeout Detection

tests/__init__.py:
- Import test_session_detector Module

Diese Änderungen sind essentiell für SessionDetector!
Ohne sie würde der Detector nicht aufgerufen werden.
2026-01-30 16:49:50 +01:00
..
models feat: SessionDetector Integration - Live-Tracking & Timeout Worker 2026-01-30 16:49:50 +01:00
python_prototype WIP: MQTT Tests - Mocked approach created but needs better testing strategy 2026-01-25 10:15:52 +01:00
security feat: MQTT integration - auto-start, session detection, UI fixes 2026-01-24 23:40:03 +01:00
services feat: SessionDetector Integration - Live-Tracking & Timeout Worker 2026-01-30 16:49:50 +01:00
tests feat: SessionDetector Integration - Live-Tracking & Timeout Worker 2026-01-30 16:49:50 +01:00
views WIP: MQTT Tests - Mocked approach created but needs better testing strategy 2026-01-25 10:15:52 +01:00
__init__.py feat: MQTT integration - auto-start, session detection, UI fixes 2026-01-24 23:40:03 +01:00
__manifest__.py feat: MQTT integration - auto-start, session detection, UI fixes 2026-01-24 23:40:03 +01:00
FEATURE_REQUEST_OPEN_WORKSHOP_MQTT_IoT.md feat(mqtt): Implement M0-M3 - MQTT IoT Bridge with Session Detection 2026-01-22 19:59:17 +01:00
README.md feat: MQTT integration - auto-start, session detection, UI fixes 2026-01-24 23:40:03 +01:00
run-tests.sh fix: Repariere alle Unit Tests - SessionDetector jetzt produktionsreif 2026-01-30 16:46:35 +01:00
TODO.md fix: Repariere alle Unit Tests - SessionDetector jetzt produktionsreif 2026-01-30 16:46:35 +01:00

Open Workshop MQTT

MQTT IoT Device Integration for Odoo 18

Features

  • MQTT Broker Connection - Connect to external MQTT brokers (Mosquitto, etc.)
  • Device Management - Configure and monitor IoT devices
  • Session Tracking - Automatic runtime session detection
  • Flexible Parsers - Support for Shelly PM Mini G3, Tasmota, Generic JSON
  • Session Strategies - Power threshold, Last Will Testament, Manual control
  • Analytics - Pivot tables and graphs for runtime analysis
  • Auto-Reconnect - Exponential backoff on connection loss
  • Message Logging - Debug log for MQTT messages

Installation

  1. Install Python dependencies:

    pip install paho-mqtt
    
  2. Install the module in Odoo:

    • Apps → Update Apps List
    • Search for "Open Workshop MQTT"
    • Click Install

Quick Start

  1. Create MQTT Connection

    • MQTT → Connections → Create
    • Enter broker details (host, port, credentials)
    • Click "Test Connection" then "Start"
  2. Add Device

    • MQTT → Devices → Create
    • Select connection
    • Configure device ID and topic pattern
    • Choose parser type (Shelly, Tasmota, etc.)
    • Set session detection strategy
  3. Monitor Sessions

    • MQTT → Sessions
    • View runtime analytics in Pivot/Graph views

Session Detection Strategies

  • Dual threshold detection (standby/working)
  • Configurable debounce timers
  • Timeout detection
  • Reference: python_prototype/session_detector.py

Last Will Testament

  • Uses MQTT LWT for offline detection
  • Immediate session end on device disconnect

Manual

  • Start/stop sessions via buttons or MQTT commands

Configuration Example

Shelly PM Mini G3:

{
  "standby_threshold_w": 20,
  "working_threshold_w": 100,
  "start_debounce_s": 3,
  "stop_debounce_s": 15,
  "message_timeout_s": 20
}

Optional: Maintenance Integration

Install open_workshop_mqtt_maintenance (separate module) to link MQTT devices to maintenance.equipment.

Technical Reference

See python_prototype/ directory for:

  • Implementation reference
  • Test suite (pytest)
  • Session detection logic
  • MQTT client implementation

Support

  • Documentation: See python_prototype/README.md
  • Issues: GitHub Issues
  • Tests: pytest python_prototype/tests/ -v

License

LGPL-3