core: Opower not working for PSE

The problem

Continually recieve internal server error when setting up Opower for PSE. Log message is Config entry 'Puget Sound Energy (PSE) (sethrait)' for opower integration not ready yet: 500, message='Internal Server Error', url=URL('https://pse.opower.com/ei/edge/apis/DataBrowser-v1/cws/cost/utilityAccount/<ACCOUNT_NUMBER>?aggregateType=day&startDate=2022-07-10T00:00:00-07:00&endDate=2023-07-08T00:00:00-07:00'); Retrying in background

What version of Home Assistant Core has the issue?

core-2023.8.4

What was the last working version of Home Assistant Core?

NA

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Opower

Link to integration documentation on our website

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

Diagnostics information

Logs from running opower’s demo.py locally (with certain values redacted):

python : DEBUG:C:\Users\sethr\repos\opower\src\opower\opower.py:Fetching: https://pse.opower.com/ei/edge/apis/multi-account-v1/cws/pse/customers?offset=0&batchSize=100&addressFilter= At line:1 char:1

  • python src/demo.py --utility pse --username sethrait --password 8wEiT …
  •   + CategoryInfo          : NotSpecified: (DEBUG:C:\Users\...&addressFilter=:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    

DEBUG:C:\Users\sethr\repos\opower\src\opower\opower.py:Fetched: { “customers”: [ { “id”: REDACTED_ID, “uuid”: “REDACTED_UUID”, “legacyOpowerId”: “43-1-5ff8aa”, “accountNumber”: “REDACTED_ACCOUNT_NUMBER”, “accountName”: “REDACTED_ADDRESS”, “address”: { “uuid”: “", “streetNumber”: "”, “streetName”: “****”, “subpremise”: null, “postalCode”: “*****”, “city”: “SEATTLE”, “country”: “US”, “state”: “WA” }, “type”: “RESIDENTIAL”, “utilityAccounts”: [ { “id”: REDACTED_ID, “uuid”: “REDACTED_UUID”, “utilityAccountId”: " REDACTED_ID_2", “utilityAccountId2”: null, “servicePointId”: REDACTED_ID_3, “meterType”: “GAS”, “preferredUtilityAccountId”: " REDACTED_ID_2", “readResolution”: “QUARTER_HOUR” } ] } ], “offset”: 0, “batchSize”: 100, “total”: 1 } DEBUG:C:\Users\sethr\repos\opower\src\opower\opower.py:Fetching: https://pse.opower.com/ei/edge/apis/bill-forecast-cws-v1/cws/pse/customers/REDACTED_UUID/combined-forecast DEBUG:C:\Users\sethr\repos\opower\src\opower\opower.py:Fetched: { “isValidUser”: true, “totalForecast”: { “meterType”: “COMBINED”, “startDate”: “2023-09-02”, “endDate”: “2023-10-01”, “currentDate”: “2023-09-05”, “daysInPeriod”: 30, “currentDay”: 4, “daysLeftInBill”: 26, “forecastedUsage”: 114, “forecastedCost”: 0, “typicalUsage”: 169, “typicalCost”: 0, “budgetBilling”: false, “costToDate”: 0, “usageToDate”: 8, “currencySymbol”: “$” }, “totalMetadata”: [ “NO_FORECASTED_COST”, “ESTIMATED_PREVIOUS_BILL” ], “accountForecasts”: [ { “unitOfMeasure”: “THERM”, “meterType”: “GAS”, “startDate”: “2023-09-02”, “endDate”: “2023-10-01”, “currentDate”: “2023-09-05”, “daysInPeriod”: 30, “currentDay”: 4, “daysLeftInBill”: 26, “forecastedUsage”: 9, “typicalUsage”: 14, “budgetBilling”: false, “usageToDate”: 1, “currencySymbol”: “$”, “preferredUtilityAccountId”: “REDACTED_ID_2”, “accountUuids”: [ “REDACTED_UUID” ], “isSolar”: false } ] } DEBUG:C:\Users\sethr\repos\opower\src\opower\opower.py:Fetching: https://pse.opower.com/ei/edge/apis/DataBrowser-v1/cws/cost/utilityAccount/REDACTED_UUID?aggregateType=day&startDate=2023-08-29T00%3A00%3A00-07%3A00&endDate=2023-09-06T00%3A00%3A00-07%3A00 DEBUG:C:\Users\sethr\repos\opower\src\opower\opower.py:Fetched: { “servicePointId”: “6001816530”, “utilityAccountUuid”: “REDACTED_UUID”, “unit”: “THERM”, “siteTimeZoneId”: “America/Los_Angeles”, “reads”: [ { “startTime”: “2023-08-29T00:00:00.000-07:00”, “endTime”: “2023-08-30T00:00:00.000-07:00”, “value”: 0, “readType”: “ESTIMATED”, “providedCost”: 0, “readComponents”: [], “isPeakPeriod”: false, “rebateAmount”: 0, “milesDriven”: 0 }, { “startTime”: “2023-08-30T00:00:00.000-07:00”, “endTime”: “2023-08-31T00:00:00.000-07:00”, “value”: 0.22, “readType”: “ESTIMATED”, “providedCost”: 0, “readComponents”: [], “isPeakPeriod”: false, “rebateAmount”: 0, “milesDriven”: 2 }, { “startTime”: “2023-08-31T00:00:00.000-07:00”, “endTime”: “2023-09-01T00:00:00.000-07:00”, “value”: 0.34, “readType”: “ESTIMATED”, “providedCost”: 0, “readComponents”: [], “isPeakPeriod”: false, “rebateAmount”: 0, “milesDriven”: 4 }, { “startTime”: “2023-09-01T00:00:00.000-07:00”, “endTime”: “2023-09-02T00:00:00.000-07:00”, “value”: 0.48, “readType”: “ESTIMATED”, “providedCost”: 0, “readComponents”: [], “isPeakPeriod”: false, “rebateAmount”: 0, “milesDriven”: 6 }, { “startTime”: “2023-09-02T00:00:00.000-07:00”, “endTime”: “2023-09-03T00:00:00.000-07:00”, “value”: 0.64, “readType”: “ESTIMATED”, “providedCost”: 0, “readComponents”: [], “isPeakPeriod”: false, “rebateAmount”: 0, “milesDriven”: 8 }, { “startTime”: “2023-09-03T00:00:00.000-07:00”, “endTime”: “2023-09-04T00:00:00.000-07:00”, “value”: 0, “readType”: “ACTUAL”, “providedCost”: 0, “readComponents”: [], “isPeakPeriod”: false, “rebateAmount”: 0, “milesDriven”: 0 } ], “seriesComponents”: [], “ratePlans”: [] }

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Reactions: 2
  • Comments: 38 (12 by maintainers)

Most upvoted comments

I noticed I was running the linuxserver/version of the container so I switched to the official one today. Unfortunately, the same problem persists.

Core version is 2024.1.2

  1. I’m able to add the OPower integration service although it seems to take awhile to validate my PSE credentials (~50 seconds). It says it is successful, but then in services it says setup failed.
  2. The initialization process takes around 8 minutes to fail, no errors are shown, no exceptions are shown, when it says success: False it claims the process took around a minute.
  3. My PSE web login works correctly and shows energy usage etc.

Are there any logging/debug options I can enable to get more information? Is there any way to verify the OPower version?

If I run the stand alone OPower (https://github.com/tronikos/opower) I get usage data:

NOTE: We don’t use gas very often anymore so the 0’s are normal for us.

DEBUG:C:\Applications\OPower\src\opower\opower.py:Fetching: https://pse.opower.com/ei/edge/apis/multi-account-v1/cws/pse/customers?offset=0&batchSize=100&addressFilter=
DEBUG:C:\Applications\OPower\src\opower\opower.py:Fetching: https://pse.opower.com/ei/edge/apis/bill-forecast-cws-v1/cws/pse/customers/REDACTED/combined-forecast
DEBUG:C:\Applications\OPower\src\opower\opower.py:Ignoring combined-forecast since there is no usage or cost. metadata: ['NO_FORECASTED_COST', 'NO_FORECASTED_USAGE', 'ESTIMATED_PREVIOUS_BILL']

Getting historical data: account= Account(customer=Customer(uuid='REDACTED'), uuid='REDACTED2', utility_account_id='REDACTED_ACCOUNTID', meter_type=<MeterType.ELEC: 'ELEC'>, read_resolution=<ReadResolution.QUARTER_HOUR: 'QUARTER_HOUR'>) aggregate_type= day start_date= 2023-12-31 12:10:14.678458 end_date= 2024-01-07 12:10:14.678458
DEBUG:C:\Applications\OPower\src\opower\opower.py:Fetching: https://pse.opower.com/ei/edge/apis/DataBrowser-v1/cws/utilities/pse/utilityAccounts/REDACTED2/reads?aggregateType=day&startDate=2023-12-31&endDate=2024-01-08
start_time      end_time        consumption     start_minus_prev_end    end_minus_prev_end
2023-12-31 00:00:00-08:00       2024-01-01 00:00:00-08:00       54.489  None    None
2024-01-01 00:00:00-08:00       2024-01-02 00:00:00-08:00       65.166  0:00:00 1 day, 0:00:00
2024-01-02 00:00:00-08:00       2024-01-03 00:00:00-08:00       62.3388 0:00:00 1 day, 0:00:00
2024-01-03 00:00:00-08:00       2024-01-04 00:00:00-08:00       57.8064 0:00:00 1 day, 0:00:00
2024-01-04 00:00:00-08:00       2024-01-05 00:00:00-08:00       57.9972 0:00:00 1 day, 0:00:00
2024-01-05 00:00:00-08:00       2024-01-06 00:00:00-08:00       62.1282 0:00:00 1 day, 0:00:00
2024-01-06 00:00:00-08:00       2024-01-07 00:00:00-08:00       24.2676 0:00:00 1 day, 0:00:00


Getting historical data: account= Account(customer=Customer(uuid='REDACTED'), uuid='REDACTED2', utility_account_id='REDACTED_ACCOUNTID', meter_type=<MeterType.GAS: 'GAS'>, read_resolution=<ReadResolution.QUARTER_HOUR: 'QUARTER_HOUR'>) aggregate_type= day start_date= 2023-12-31 12:10:14.678458 end_date= 2024-01-07 12:10:14.678458
DEBUG:C:\Applications\OPower\src\opower\opower.py:Fetching: https://pse.opower.com/ei/edge/apis/DataBrowser-v1/cws/utilities/pse/utilityAccounts/REDACTED2/reads?aggregateType=day&startDate=2023-12-31&endDate=2024-01-08
start_time      end_time        consumption     start_minus_prev_end    end_minus_prev_end
2023-12-31 00:00:00-08:00       2024-01-01 00:00:00-08:00       0       None    None
2024-01-01 00:00:00-08:00       2024-01-02 00:00:00-08:00       0       0:00:00 1 day, 0:00:00
2024-01-02 00:00:00-08:00       2024-01-03 00:00:00-08:00       0       0:00:00 1 day, 0:00:00
2024-01-03 00:00:00-08:00       2024-01-04 00:00:00-08:00       0       0:00:00 1 day, 0:00:00
2024-01-04 00:00:00-08:00       2024-01-05 00:00:00-08:00       0       0:00:00 1 day, 0:00:00
2024-01-05 00:00:00-08:00       2024-01-06 00:00:00-08:00       0       0:00:00 1 day, 0:00:00

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000029C769711F0>
Traceback (most recent call last):
  File "C:\Python\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Python\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Python\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Python\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000029C769711F0>
Traceback (most recent call last):
  File "C:\Python\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Python\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Python\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Python\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

If I copy demo.py from the OPower project for the Home Assistant container to use and run OPower directly from a bash terminal window, I get usage data. So I think this is a bug in the HA integration.

(I have no idea what’s with the exception at the end, it doesn’t occur in the HA container run.)

Gave it another try today! it’s working!

This is likely the same as https://github.com/tronikos/opower/issues/32 and we need to reduce the max_request_days