ha-emporia-vue icon indicating copy to clipboard operation
ha-emporia-vue copied to clipboard

Fetch the previous minute to ensure completeness

Open amscanne opened this issue 2 years ago • 3 comments

Since there is no reset that occurs for the MINUTE scale, ensure that we have a complete data point by using the previous minute. Initial results suggests that this eliminates noise I see using Emporia Vue Connect (but I can let it bake longer, and figured I'd send the PR in case there's some fundamental fact that I'm missing).

amscanne avatar Oct 29 '22 00:10 amscanne

I believe the API will return the last full minute data, not the current partial one, which is why there's currently an up to two minute delay between turning something on and the usage showing up in Home Assistant. The API also sometimes just returns 0 or None so this might be a way to prevent those results. I think I might provide this as an option, since I've got one set of people who want the delay to be smaller so they can automate on devices turning on/off and another set who want more reliable data for historical purposes.

What were you seeing before this change? Empty/0 values or partial values?

magico13 avatar Oct 31 '22 16:10 magico13

I like your idea. I think you would need to do a request for every channel? (will look at repo)

I forked pyemvue and have it running without missing data for about half a day now adding sanity checking and retries for the valid / empty response (just nulls on first meter) bug on api.emporia-energy.com and retries for the server returning 500 server unavailable. Data is clean about 11 hours now. (test still running). I will put a pull request in pyemvue next week if it's still good. Issue 39 on pyemvue.

DabblerIOT avatar Feb 16 '24 15:02 DabblerIOT

Looked at your fix. Is this intended to fix values logged as 0, none, or unknown? If so I don't think the problem is with the time or incorrect, but it is with emporia server returning a bogus message or a 500 error. I coded in retries on issue 39 on pyemvue.

If you really have verified this is an issue (not sure how you could have) my question would be is one second enough.. I doubt the time on all of our systems is accurate to the second.

DabblerIOT avatar Feb 16 '24 15:02 DabblerIOT