Go to file
matthias.lotz 7337e57b40 feat: Implement Odoo Config-Push System (Phase 3.2)
Completes PUSH architecture - Odoo automatically pushes config to Bridge

NEW FEATURES:
- Model Hooks in mqtt.device (create/write/unlink)
  - Automatically push config after device create/update/delete
  - Smart detection: only relevant fields trigger push
  - Non-blocking: UI works even if bridge is offline

- Config Builder (_build_bridge_config)
  - Collects all active mqtt.device records
  - Converts to Bridge-compatible JSON format
  - Topic pattern transformation (/#→/status/pm1:0)
  - Session config extraction from strategy_config JSON
  - Returns BridgeConfig schema with timestamp + version

- HTTP Client with Retry Logic (_push_bridge_config)
  - POST to bridge_url/config with JSON payload
  - 3 retries with exponential backoff (1s, 2s, 4s)
  - Timeout: 10 seconds per request
  - Error handling: 4xx no retry, 5xx retry
  - Returns success/message dict for UI notifications

- System Parameter for Bridge URL
  - Configurable via ir.config_parameter
  - Key: open_workshop_mqtt.bridge_url
  - Default: http://iot-bridge:8080
  - Stored in data/system_parameters.xml

- Manual Push Button in UI
  - '🔄 Push Config to Bridge' button in device list header
  - Calls action_push_config_to_bridge()
  - Shows success/error notification toast
  - Allows manual sync when needed

NEW FILES:
- data/system_parameters.xml                          - Bridge URL param
- tests/test_config_push_integration.py              - Python integration test

MODIFIED FILES:
- models/mqtt_device.py                              - +250 lines (hooks, builder, client)
- views/mqtt_device_views.xml                        - Manual push button
- __manifest__.py                                    - requests dependency, data file

ARCHITECTURE CHANGE:
Before: Bridge pulls config from Odoo via GET /api/config
After:  Odoo pushes config to Bridge via POST /config
        - Triggered automatically on device changes (create/write/unlink)
        - Manual trigger via UI button
        - Bridge receives validated config via FastAPI endpoint

TESTING:
 Model hooks fire on create/write/unlink
 Config builder generates valid JSON
 HTTP client successfully pushes to bridge
 Retry logic works (tested with bridge down→up)
 Manual button displays notifications
 Bridge receives and applies config
 Device add/update/remove reflected in bridge

NEXT STEP:
Phase 3.3 - Remove legacy get_config() from bridge (no longer needed)
2026-02-12 20:18:13 +01:00
extra-addons/open_workshop/open_workshop_mqtt feat: Implement Odoo Config-Push System (Phase 3.2) 2026-02-12 20:18:13 +01:00
iot_bridge feat: Implement HTTP Config API for Bridge (Phase 3.1) 2026-02-12 20:05:49 +01:00
odoo@fd43f0445a initial MQTT Development 2026-02-11 21:07:32 +01:00
python_proto_type added python_proto_type 2026-02-10 20:13:58 +01:00
.gitignore initial version 2026-02-10 20:00:27 +01:00
FEATURE_REQUEST_OPEN_WORKSHOP_MQTT_IoT.md fix: Make IoT Bridge autonomous and fix session closing 2026-02-12 19:28:25 +01:00
IMPLEMENTATION_PLAN.md feat: Implement Odoo Config-Push System (Phase 3.2) 2026-02-12 20:18:13 +01:00