Skip to content
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

How to get In/out to grid kWh #51

Open
rupesh97 opened this issue May 1, 2023 · 2 comments
Open

How to get In/out to grid kWh #51

rupesh97 opened this issue May 1, 2023 · 2 comments

Comments

@rupesh97
Copy link

rupesh97 commented May 1, 2023

First, thank you for creating this API. I have had great success with it. Among other things, I am using get_chart_usage() to fetch daily energy usage for various circuits.

For the main panel, I can retrieve the net energy flow for the day. We have solar, so power flows in both directions and this number can be positive or negative. However, I'd like to separately query "In from Grid" and "Out to Grid" kWh (what I'm getting is essentially a difference of the two). This should be possible since the Emporia UI shows those numbers separately for durations >= DAY, but I can't figure out how to do that with this API.

@magico13
Copy link
Owner

magico13 commented May 1, 2023

I don't have solar so those don't come up for me but I believe you can get them from the get_device_list_usage endpoint, which is the one that maps to the data you see on the homepage of the Emporia app.

If you use a call like device_usage_dict = vue.get_device_list_usage(deviceGids=device_gids, instant=None, scale=Scale.DAY.value, unit=Unit.KWH.value) then there should be two channels on the main device, one for the To Grid and one for the From Grid. See this example for how to iterate through the object you get back from that call https://github.com/magico13/PyEmVue#typical-example---getting-recent-usage

Note that if you just want the daily data you can get on the main page of the app, that call will get the data for every device and channel in just one call, rather than making separate calls to the get_chart_usage endpoint. The get_chart_usage endpoint is good if you want data over a time range since it unsurprisingly corresponds to the "Graphs" page in the app.

@rupesh97
Copy link
Author

rupesh97 commented May 1, 2023

Thanks a ton Mike for leading me down the right path. I'm finding Emporia's internals quite confusing, with terms like "channel" overloaded to mean different things depending on the context.

As you point out, get_device_list_usage and get_chart_usage are purpose built calls to solve their own respective problems in Emporia's UI. I am able to get what I need from the former (but not latter) as channels MainsFromGrid and MainsToGrid. The fact that get_chart_usage doesn't return these measurements is consistent with the fact that you can't plot them over time in the Emporia UI.

PS: I am cognizant of the high query rate concerns that you may be alluding to. I am building a simple command line tool that I intend to query once/month to reconcile my utility bill with Emporia's measurements, so it shouldn't put any non trivial load on their servers.

Thanks again

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

No branches or pull requests

2 participants