-
Notifications
You must be signed in to change notification settings - Fork 70
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
Energy consumption & Usage from history_stats #111
Comments
Well... you're not completely misunderstanding it. Perhaps I should not have called that item If you want to compute cumulative energy since some point of time, you'll need to call One more thing. While this: history_stats(parse_samples=-1, context=ChannelContext(target="..."))[-1]["total_energy"]
^^^^ will currently work to pull the power stats dict out of the return value, I would not recommend that exact usage, as it will break if there is ever another dict added to the |
Ah I see! I should have read through the code more carefully! Could be then used periodical call of
Sure! Will do. 😉 |
Yes, that will work, too, it will just use a bit more memory, as you'd be keeping around an ever-growing history buffer, and be a bit less performant, as the code in Note that the same approach of tracking the end counter and keeping cumulate totals could be applied to the upload and download usage data, too, but I suppose just keeping a concatenated history buffer is a somewhat simpler. |
Yeah, that's what I thought too... maybe caching of I'll compare both approaches and will see, thanks for your insight. 👍 |
So for anyone wondering I did chose this method (it's not full & working code):
|
Hi @sparky8512, first of all great job and thanks for your work!
I have recently added power consumption (
PowerDict
) to the Home Assistant andlatest_power
works great but we noticed thatparse_samples=-1
which (if I understood correctly) should compute stats above all available dataseems odd and doesn't really "add up" and increase w/ time.
And it seems it's the same for
UsageDict
too (does not increase w/ time since reboot).I did take your word for it that it should compute energy since reboot, or am I just misunderstanding this feature completely?
Cheers!
The text was updated successfully, but these errors were encountered: