Keep last public API sensor values while offline#714
Open
bluesk1d wants to merge 1 commit into
Open
Conversation
4 tasks
|
Does this cover the behavior of the stream mini? This device is going offline without sun |
Contributor
Author
|
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. |
|
I've been using it for a week now and it works perfectly. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes public API sensor values flapping between their real reading and
0when 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:
0is a real measurementIn practice this showed up as repeated flapping such as:
0Root 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:
assume_offline/offline0Why this is safer
For public API devices, a stale last-known value plus an offline status is more accurate than fabricating
0readings during transient outages.Files
custom_components/ecoflow_cloud/entities/__init__.pyVerification
python -m compileall