Problem: Device Status Monitor was using a hardcoded 30-second global timeout for marking devices offline, independent of the configurable message_timeout_s. This caused alternating offline/online events for devices with power=0 that don't send frequent MQTT messages. Solution: Use the same timeout value (message_timeout_s) for both: 1. Session Detection (message_timeout_s) 2. Device Status Monitoring (device_status_timeout_s) Implementation: - Add device_status_timeout_s field to api/models.py DeviceConfig (default: 120s) - Update Odoo iot_api.py to include device_status_timeout_s in config response (synchronized with message_timeout_s from device strategy config) - Update Bridge service_manager.py to use device_status_timeout_s when initializing DeviceStatusMonitor (fallback to global config if not provided) Result: - Single configurable timeout per device in Odoo - Both checks (session + device status) use same value - Backward compatible (defaults to 120s if not provided) - Solves alternating offline/online events for low-power/idle devices Validation: - mypy: 0 errors across 47 files - API model test: device_status_timeout_s field functional |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| models.py | ||
| server.py | ||