tronikos / opower-hacs

HACS integration for PG&E via Opower
10 stars 2 forks source link

Support for multiple customers in PG&E #6

Closed FrancoisHuet closed 1 year ago

FrancoisHuet commented 1 year ago

First, huge thanks for working on this extension!

In trying it (install in custom_components), I found that only my PG&E Gas information was included.

I dug into this a bit, looking through the API calls. It seems that my PG&E account is modeled as two different customer IDs, possibly because I have solar. Since the python code in _async_get_customer includes a commented out line showing how to get multiple customers, I made a few edits, to turn that function into an _async_get_customers, and tested via demo.py.
I was able to see both electric and gas accounts (so, progress!), though getting historical data for Electric gave me a forbidden.

aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://pge.opower.com/ei/edge/apis/DataBrowser-v1/cws/utilities/pge/utilityAccounts/<redacted>/reads?aggregateType=hour&startDate=2023-05-27&endDate=2023-06-04')

If you don't mind giving me a few pointers, I could try to take this a bit further.

tronikos commented 1 year ago

Do you see historical data on PGE's site? If yes, and you are determined, you can reverse engineer it on your own.

FrancoisHuet commented 1 year ago

I've made good progress on this and should have something for you shortly. My only concern is that I know how to test via demo.py, but I might need pointers to figure out how to test in home assistant directly. Thanks again!

tronikos commented 1 year ago

Great to hear. If it works in demo.py it should work in Home Assistant too. You can test it by following these instructions: https://developers.home-assistant.io/docs/api_lib_index?_highlight=library#trying-your-library-inside-home-assistant

Since you mentioned you have solar it would be great if you could also fix https://github.com/tronikos/opower-hacs/issues/4

I also have solar but I'm still waiting for PTO...

tronikos commented 1 year ago

Or if you prefer, since it will likely be easier, after merging your changes I can publish a prerelease version for you to test. If you need any help you can reach out to me in the Home Assistant discord server under the same username.

FrancoisHuet commented 1 year ago

Pull request on its way. I tried to find you on discord but didn't. I'm FrzInSC there. Thanks!

tronikos commented 1 year ago

Published a new release. Thanks for your contribution! Since you have solar it would be good to comment on #4 whether you encounter that issue.

FrancoisHuet commented 1 year ago

Will do, I tried to repro but it didn't happen for me. Thanks for building this!