magico13 / PyEmVue

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

1MIN scale not working #37

Closed c3p0vsr2d2 closed 2 years ago

c3p0vsr2d2 commented 2 years ago

I get a 404 error with a scale of 1MIN, the error is the following:

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.emporiaenergy.com/AppAPI?apiMethod=getChartUsage&deviceGid=XXXXX&channel=1,2,3&start=2022-06-03T23:24:44.206428Z&end=2022-06-05T23:24:44.206467Z&scale=1MIN&energyUnit=KilowattHours

magico13 commented 2 years ago

Try deviceGids instead of deviceGid even though you're only using one

Cuervocartoon commented 2 years ago

Hi there, I'm getting the same error:

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.emporiaenergy.com/AppAPI?apiMethod=getChartUsage&deviceGid=XXXXXX&channel=1,2,3&start=2022-05-31T17:00:00Z&end=2022-06-07T04:59:59Z&scale=15MIN&energyUnit=KilowattHours

Even changing the code:

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.emporiaenergy.com/AppAPI?apiMethod=getChartUsage&deviceGids=XXXXXX&channel=1,2,3&start=2022-05-31T17:00:00Z&end=2022-06-07T04:59:59Z&scale=15MIN&energyUnit=KilowattHours

Perhaps the API changed?

Thank you for your efforts.

c3p0vsr2d2 commented 2 years ago

Try deviceGids instead of deviceGid even though you're only using one

How do I change the URL directly (change the package code, or something else)?

I also discovered I can get the old URL to work if the duration requested is 12 hours or less. A workaround now is multiple get_chart_usage() calls each for a 12 hour duration.

magico13 commented 2 years ago

Sorry, I saw the URL and my brain jumped to hitting the API directly, I forgot that the URLs are baked into the library. Yeah, most likely they have implemented API-side restrictions to limit the amount of data you can request at one time. I didn't catch that you were requesting two days worth of data.

@Cuervocartoon you probably have a similar problem since it looks like you're getting 1 week of data at the 15 minute scale, try limiting that to a day at a time, or even 12 hours if one day isn't small enough.

Cuervocartoon commented 2 years ago

Thank you for the fast reply, it was right the problem.

c3p0vsr2d2 commented 2 years ago

Thanks @magico13, I will close this issue for now. Seems like some restrictions being added on Vue's side. Thanks for the help.