-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metric timestamps and metric timeout (fixes #64, #67) #69
base: master
Are you sure you want to change the base?
Conversation
Some context -- it appears that EcoFlow is trickling updates at a slower rate than previously, which was invoking the "erase everything" logic whenever 10 seconds (COLLECTING_INTERVAL) would pass between messages. Now, we expire each metric individually (METRIC_TIMEOUT or 60 seconds). We also add a timestamp to each metric to expose its staleness. In order to keep the timestamp accurate, we now process messages immediately rather than in batches (no more COLLECTING_INTERVAL). Finally, we introduce DEVICE_TIMEOUT (30 seconds), which controls whether a device is considered "online". Each message from MQTT (even unprocessed) resets this timer.
Some further testing may be warranted to determine the appropriate value for
(but, this is at least an improvement -- most of the important panels work OK, such as battery SoC) |
Further observation reveals:
It's not a pretty solution. I hope someone finds #70 and can shed some light onto how to fix this properly. EcoFlow does have an official API now (which includes MQTT!), so maybe that'll be a viable direction. (I requested a developer account.) There's a fairly active Facebook group for said API, even including one EcoFlow employee... fingers crossed that they're actually listening to what we need. |
Wow, you've really gone in depth here @tris! Thanks for all of the work that you put into understanding this. I think that if I'm reading everything correctly, that it seems like even this PR may not fix all of the issues that you've seen with slowness of messages. Is that accurate? If so, then it seems like the official API might be the best next path forward as from #70 it doesn't seem like we can forge the right identity to get messages coming in the same way that the official apps do. Does that seem accurate as well? Also, if we go the official API route, does that mean that each user of the exporter will need to request private developer API credentials in order to run the exporter? |
Yeah, that's accurate. The only real fix here is that we no longer wipe metrics possibly before they even get scraped, so there's a slightly better chance of the metric actually making it to Prometheus (though raising the The other "fix" is more a nice-to-have than anything -- putting timestamps on the metrics prevents storing stale or duplicate data in Prometheus, and ensures the stats you're looking at are from the correct time. (I feel this becomes a bit more important in this case where we're only getting updates every 15 minutes.)
Yep, unless someone figures out the signature -- maybe over in tolwi/hassio-ecoflow-cloud or v1ckxy/ecoflow-withoutflow...
Yep; this is what I see at https://developer.ecoflow.com/us/verify:
...so, not like some other developer platforms which issue one token to identify the app/developer while using a separate mechanism to authenticate the user -- they're catering to the hobbyist use case only. (But then, why the manual review for hobbyist accounts?) |
I’m sorry, I’m just a docker image user, how do I implement this fix right now? Can someone help? |
Easiest for right now is probably:
and then use that local image ( |
Just FYI: https://github.com/michikrug/ecoflow_exporter/blob/api/ecoflow_exporter.py |
I rewrote the exporter to use public API authentication and MQTT. It has worked well for me over the past two days. I created a fork for this so users with public API access can use it immediately. If you want to migrate from username/password authentication, I'd be happy if you adopt my changes in the original repository. https://github.com/dmitry-semenov/ecoflow_exporter/blob/master/ecoflow_exporter.py |
hello @tris, first of all, thank you for your work, please let me know if I'm doing something wrong.
But I receive an error for ecoflow_exporter container if ecoflow android application is closed |
Some context -- it appears that EcoFlow is trickling updates at a slower rate than previously, which was invoking the "erase everything" logic whenever 10 seconds (
COLLECTING_INTERVAL
) would pass between messages.Now, we expire each metric individually (
METRIC_TIMEOUT
or 60 seconds). We also add a timestamp to each metric to expose its staleness.In order to keep the timestamp accurate, we now process messages immediately rather than in batches (no more
COLLECTING_INTERVAL
).Finally, we introduce
DEVICE_TIMEOUT
(30 seconds), which controls whether a device is considered "online". Each message from MQTT (even unprocessed) resets this timer.