home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.02k stars 29.09k forks source link

Opower - Peco :: ClientResponseError: 400 when calling ADI #110979

Open ichrispod opened 5 months ago

ichrispod commented 5 months ago

The problem

When calling the https://secure.peco.com/api/Services/OpowerService.svc/GetOpowerToken API, I'm getting an HTTP 400

Logger: homeassistant.components.opower.coordinator Source: helpers/update_coordinator.py:313 Integration: Opower (documentation, issues) First occurred: 5:56:32 PM (6 occurrences) Last logged: 6:00:01 PM

Unexpected error fetching Opower data: 400, message='Bad Request', url=URL('https://secure.peco.com/api/Services/OpowerService.svc/GetOpowerToken') Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/opower/opower.py", line 194, in async_login self.access_token = await self.utility.async_login( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/opower/utilities/exelon.py", line 209, in async_login async with session.post( File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 693, in _request resp.raise_for_status() File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://secure.peco.com/api/Services/OpowerService.svc/GetOpowerToken')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/opower/coordinator.py", line 80, in _async_update_data await self.api.async_login() File "/usr/local/lib/python3.12/site-packages/opower/opower.py", line 202, in async_login raise CannotConnect(err) opower.exceptions.CannotConnect: 400, message='Bad Request', url=URL('https://secure.peco.com/api/Services/OpowerService.svc/GetOpowerToken')

What version of Home Assistant Core has the issue?

core-2024.2.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Opower

Link to integration documentation on our website

https://www.home-assistant.io/integrations/opower

Diagnostics information

Logger: homeassistant.components.opower.coordinator Source: helpers/update_coordinator.py:313 Integration: Opower (documentation, issues) First occurred: 5:56:32 PM (6 occurrences) Last logged: 6:00:01 PM

Unexpected error fetching Opower data: 400, message='Bad Request', url=URL('https://secure.peco.com/api/Services/OpowerService.svc/GetOpowerToken') Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/opower/opower.py", line 194, in async_login self.access_token = await self.utility.async_login( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/opower/utilities/exelon.py", line 209, in async_login async with session.post( File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 693, in _request resp.raise_for_status() File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://secure.peco.com/api/Services/OpowerService.svc/GetOpowerToken')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/opower/coordinator.py", line 80, in _async_update_data await self.api.async_login() File "/usr/local/lib/python3.12/site-packages/opower/opower.py", line 202, in async_login raise CannotConnect(err) opower.exceptions.CannotConnect: 400, message='Bad Request', url=URL('https://secure.peco.com/api/Services/OpowerService.svc/GetOpowerToken')

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 5 months ago

Hey there @tronikos, mind taking a look at this issue as it has been labeled with an integration (opower) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `opower` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign opower` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


opower documentation opower source (message by IssueLinks)

bens545 commented 5 months ago

I think this is related to transition to a new billing system. It's not currently possible to login to their website either.

image

ichrispod commented 5 months ago

Thanks for the quick response! I guess it’s not going too well for PECO… it’s been a few weeks.  I’ll keep an eye on this and re-enable when site allows logins again. On Feb 19, 2024, at 10:49 PM, Ben Shaner @.***> wrote: I think this is related to transition to a new billing system. It's not currently possible to login to their website either. image.png (view on web)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

supermarkert commented 2 months ago

Any update to this? PECO did seem to switch to a new billing system (so everyone gets new account numbers). I can login to PECO's website, but the integration doesn't seem to be pulling any data. I deleted my Opower entries and added PECO back in. The GUI says it was setup correctly, but no entities are actually created. image

tronikos commented 2 months ago

Entities are only created if your utility provides forecast data. Do you get statistics?

ichrispod commented 2 months ago

It’s been hit or miss for me with Peco. It worked a few days ago and now it’s dead again. Nothing in the logs indicate a problem.

Happy to provide any information you might need.

On Apr 23, 2024, at 2:11 PM, tronikos @.***> wrote:

Entities are only created if your utility provides forecast data. Do you get statistics?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/110979#issuecomment-2073074835, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI2UELEDVRLYX6CPLTWSSP3Y62P5XAVCNFSM6AAAAABDQFKJWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZTGA3TIOBTGU. You are receiving this because you authored the thread.

supermarkert commented 2 months ago

Entities are only created if your utility provides forecast data. Do you get statistics?

I get historical data on Peco's website (don't think I've ever had forecast data). This integration worked fine previously and all the numbers brought in lined up with the data on Peco's website for past usage, but then seemingly the connection broke a couple months ago.
I've deleted the integration and tried adding it back in, and got the results above: it says it successfully logged in and connected, but no entities are created.

supermarkert commented 2 months ago

Update: I noticed that it magically started collecting again today, without me changing anything (except I did reboot at some point). So it was either (1) random PECO website nonsense, (2) it was because I deleted the integration a few days ago and needed to then wait 24-48 hours for it to update, or maybe (3) it was the reboot.