open_workshop/open_workshop_mqtt
matthias.lotz c55b0e59d2 feat(odoo): IoT Bridge Phase 2 - Odoo REST API
Phase 2.1 - Models:
- ows.iot.event Model für Event-Logging
  - event_uid (unique constraint) für Duplikat-Prävention
  - event_type (session_started/updated/stopped/timeout/heartbeat)
  - payload_json mit auto-extraction (power_w, state)
  - Auto-Linking zu mqtt.device und mqtt.session
  - Processing-Status tracking
- mqtt.device erweitert mit device_id (External ID für API)
- Existing mqtt.session bereits perfekt strukturiert

Phase 2.2 - REST API Controller:
- GET /ows/iot/config
  - Returns aktive Devices mit session_config als JSON
  - Public auth (später API-Key optional)
- POST /ows/iot/event
  - JSON-RPC Format (Odoo type='json')
  - Schema-Validation (required: event_uid, event_type, device_id, timestamp)
  - Duplikat-Check: 409 Conflict für idempotency
  - Auto-Processing: Session create/update/complete
  - Response codes: 201/409/400/500

Phase 2.3 - Bridge OdooClient:
- Echte REST API Implementation
  - get_config(): GET /ows/iot/config
  - send_event(): POST /ows/iot/event (JSON-RPC)
  - Duplicate handling (409 = success)
  - HTTP Session mit requests library
- config.py: OdooConfig mit base_url, database, username, api_key
- main.py: Conditional OdooClient/MockOdooClient based on use_mock

Testing Guide:
- PHASE2_TESTING.md mit kompletter Anleitung
- Manuelle API Tests (curl examples)
- Integration Test Steps (Odoo + Mosquitto + Bridge)
- Success Criteria Checklist

Bereit für Phase 2.4 Integration Testing!
2026-02-05 16:43:26 +01:00
..
controllers feat(odoo): IoT Bridge Phase 2 - Odoo REST API 2026-02-05 16:43:26 +01:00
iot_bridge feat(odoo): IoT Bridge Phase 2 - Odoo REST API 2026-02-05 16:43:26 +01:00
models feat(odoo): IoT Bridge Phase 2 - Odoo REST API 2026-02-05 16:43:26 +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(odoo): IoT Bridge Phase 2 - Odoo REST API 2026-02-05 16:43:26 +01:00
services WIP: Duplikate-Fix und ausführliche Service-Dokumentation 2026-01-31 11:19:44 +01:00
tests WIP: Duplikate-Fix und ausführliche Service-Dokumentation 2026-01-31 11:19:44 +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(odoo): IoT Bridge Phase 2 - Odoo REST API 2026-02-05 16:43:26 +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
IMPLEMENTATION_PLAN.md feat(odoo): IoT Bridge Phase 2 - Odoo REST API 2026-02-05 16:43:26 +01:00
PHASE2_TESTING.md feat(odoo): IoT Bridge Phase 2 - Odoo REST API 2026-02-05 16:43:26 +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
test-direct.sh WIP: Duplikate-Fix und ausführliche Service-Dokumentation 2026-01-31 11:19:44 +01:00
test-output.txt WIP: Duplikate-Fix und ausführliche Service-Dokumentation 2026-01-31 11:19:44 +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