Skip to content

Keep last public API sensor values while offline#714

Open
bluesk1d wants to merge 1 commit into
tolwi:mainfrom
bluesk1d:bugfix/public-api-keep-last-value
Open

Keep last public API sensor values while offline#714
bluesk1d wants to merge 1 commit into
tolwi:mainfrom
bluesk1d:bugfix/public-api-keep-last-value

Conversation

@bluesk1d
Copy link
Copy Markdown
Contributor

Summary

This fixes public API sensor values flapping between their real reading and 0 when the device briefly appears offline or stops delivering fresh quota data.

Problem

For public API devices, the integration can temporarily consider the device offline. When that happened, sensor entities with a default value were resetting themselves to that default, which commonly meant 0.

That behavior is misleading for measurement entities:

  • 0 is a real measurement
  • it does not mean "no fresh data"
  • dashboards and history end up showing false zeroes instead of preserving the last known reading

In practice this showed up as repeated flapping such as:

  • real value
  • 0
  • real value

Root Cause

The public API data merge path already keeps prior values when a response omits fields. The visible zeroing was happening later in the entity layer, where offline handling reset sensor values to _attr_default_value.

Change

This change keeps the existing reset-to-default behavior for non-public-api devices, but skips that reset for public API devices.

As a result:

  • public API status entities still report assume_offline / offline
  • public API measurement sensors keep their last known reading instead of being forced to 0

Why this is safer

For public API devices, a stale last-known value plus an offline status is more accurate than fabricating 0 readings during transient outages.

Files

  • custom_components/ecoflow_cloud/entities/__init__.py

Verification

  • Confirmed the zeroing path was in offline entity handling, not in the public API params merge
  • Compiled the updated module successfully with python -m compileall

@dMopp
Copy link
Copy Markdown

dMopp commented Mar 20, 2026

Does this cover the behavior of the stream mini? This device is going offline without sun

@bluesk1d
Copy link
Copy Markdown
Contributor Author

bluesk1d commented Mar 20, 2026

I don't have one of those but it should cover any device that is intermittently considered offline by missed API responses. It won't help if the API actually returns that a device is offline. It's just one file update so you can just drop the modified one from the PR into your custom_components/ecoflow_cloud/entities folder and see if it helps you.

@Hydrocephalic
Copy link
Copy Markdown

I've been using it for a week now and it works perfectly. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants