fix: stop sensor value flip when device is offline#770
Conversation
|
Tested this now for >24h without issues |
|
|
Unsure if I understood you right... When the device is offline at startup, Maybe me and my AI are on the wrong path, but if so, how would an offline public API device come online again in your understanding? |
|
When a device comes back online and emits MQTT messages, REST calls to |
|
Thanks. Still this seem to have not happened for my PowerStream device :/ Could it be that those status messages are not reliably sent or received? |
Problem
Two related regressions introduced in v1.5.0 affect devices connected via the public API (e.g. PowerStream) that have no MQTT heartbeat:
1. Sensor values flipping between real values and zero every 30–60 seconds while offline
The
_handle_coordinator_updatereset logic fired on every coordinator tick whileis_offline. Meanwhile,quota_all()continues polling the EcoFlow REST API on a scheduled interval — and the API returns cached data regardless of actual device status. Each quota response bumpedchanged=Truefor one tick, temporarily restoring real sensor values, before the next tick reset them back to zero. This caused continuous flipping for the entire offline period.2. Device stuck permanently offline once it passed through the
ASSUME_OFFLINEwindowThe
DeviceStatusCoordinatorpolls/device/listto recover online status, but only whenwants_status_pollisTrue— which was exclusively the case forASSUME_OFFLINE. If the coordinator tick missed theASSUME_OFFLINEwindow and the tracker decayed to fullOFFLINE,wants_status_pollreturnedFalse, the poll was permanently skipped, and the device could not recover without a full HA restart.Root cause context
The v1.5.0 changes were a deliberate fix for a v1.4.1 bug where
/device/quota/allreturning cached data for offline devices causedonline=Trueto be set unconditionally, meaning devices never showed as offline. Theis_auto=Falseflag on quotaPreparedDatawas the correct fix for that — but the recovery and reset mechanisms did not account for public-API-only devices that have no MQTT activity.Fix
devices/status_tracker.py— extendwants_status_pollto includeOFFLINE:The
StatusCoordinatorinterval is already set toassume_offline_sec(default 5 min), so this adds at most one/device/listcall per interval with no meaningful API overhead. Maximum recovery time after a device comes back online: ~5 minutes.entities/__init__.py— fire the offline reset once, suppress cached quota data while offline, and restore immediately on recovery.Key behaviours:
OFFLINEtick, then the entity is frozen at the default valuechanged=Trueticks from cached quota data — are ignored entirelyBehaviour summary
ASSUME_OFFLINEwindow