magico13 / PyEmVue

Python Library for the Emporia Vue Energy Monitor
MIT License
185 stars 36 forks source link

API change on 8/18 -> broken PyEmVue? #27

Closed DRuggeri closed 2 years ago

DRuggeri commented 2 years ago

Hello there. First, thanks for taking the time to create this library! I ended up turning this into a Prometheus exporter, FWIW :-)

I'm curious if the API has maybe changed from underneath the library. As of Aug 18 11:24:40 Central US time, I've seen 4xx errors in logs when attempting to make calls to the API.

This is the error noticed during vue.get_devices_usage(deviceGids, None, scale=Scale.MINUTE.value, unit=Unit.KWH.value), after already logged in and with all GIDs handy (unfortunately, log is truncated): requests.exceptions.HTTPError: 499 Client Error: for url: https://api.emporiaenergy.com/AppAPI?apiMethod=getDevicesUsage&deviceGids=46959+57265+57269+57276+57318+57318+57671+57671+58403+58403+5933

On restart of my monitoring daemon, I get a different error (exercising a different part of the API) when calling vue.get_devices() requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.emporiaenergy.com/customers/26086/devices?detailed=true&hierarchy=true

To be sure I didn't booger up something with my credentials or whatnot, I verified this does the same thing after logging in with credentials as well as API keys.

If it would be helpful, I can gather more detailed logs or header info. Based on Kevin's response recently on the Emporia forum (and I guess maybe Ted's here in the Issue tracker), I don't think Emporia is trying to lock PyEmVue out... maybe just an API format or header format change?

magico13 commented 2 years ago

Already fixed, you just need to update. There were some breaking changes so look at the release notes under the GitHub releases and if you have any questions let me know.

DRuggeri commented 2 years ago

Thanks, @magico13 - that's an embarrassing miss. I pulled the latest release and after refactoring (a bit on the painful side) to fit the new model, all's well. Quite happy to see the "Balance" channel appearing - so that's cool!