Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opower - Unexpected error fetching Opower data (Atlantic City Electric) #117387

Open
audiofreak9 opened this issue May 13, 2024 · 8 comments · May be fixed by #117763
Open

Opower - Unexpected error fetching Opower data (Atlantic City Electric) #117387

audiofreak9 opened this issue May 13, 2024 · 8 comments · May be fixed by #117763

Comments

@audiofreak9
Copy link

The problem

Opower fails to fetch my meter data. I can log into my Atlantic City Electric account and see my usage etc. I also have two step verification off. This integration has never worked for my account.

View-My-Usage-Atlantic-City-Electric-An-Exelon-Company
My-Security

What version of Home Assistant Core has the issue?

core-2024.5.2

What was the last working version of Home Assistant Core?

No response

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

home-assistant_opower_2024-05-13T22-20-18.047Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-05-13 18:06:04.582 DEBUG (MainThread) [homeassistant.components.opower.coordinator] Updating sensor data with: [Forecast(account=Account(customer=Customer(uuid='b7e3a76c-4016-11e7-8616-c28eda43d393'), uuid='5a5d4c9c-4017-11e7-8616-c28eda43d393', utility_account_id='4001842964', meter_type=<MeterType.ELEC: 'ELEC'>, read_resolution=None), start_date=datetime.date(2024, 4, 26), end_date=datetime.date(2024, 5, 26), current_date=datetime.date(2024, 5, 13), unit_of_measure=<UnitOfMeasure.KWH: 'KWH'>, usage_to_date=686.0, cost_to_date=157.0, forecasted_usage=1187.0, forecasted_cost=272.0, typical_usage=1223.0, typical_cost=255.0)]
2024-05-13 18:06:04.582 DEBUG (MainThread) [homeassistant.components.opower.coordinator] Updating Statistics for opower:ace_elec_4001842964_energy_cost and opower:ace_elec_4001842964_energy_consumption
2024-05-13 18:06:08.218 ERROR (MainThread) [homeassistant.components.opower.coordinator] Unexpected error fetching Opower data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/opower/coordinator.py", line 88, in _async_update_data
await self._insert_statistics()
File "/usr/src/homeassistant/homeassistant/components/opower/coordinator.py", line 137, in _insert_statistics
cost_sum = cast(float, stats[cost_statistic_id][0]["sum"])
~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'opower:ace_elec_4001842964_energy_cost'

Additional information

No response

@home-assistant
Copy link

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)

@tronikos
Copy link
Contributor

Can you install the SQLite Web addon and run the following queries and post here their results:

SELECT * FROM statistics_meta WHERE source="opower";

should return something like:

85 opower:pge_elec_XXX_energy_cost opower NULL 0 1 Opower pge elec XXX cost
86 opower:pge_elec_XXX_energy_consumption opower kWh 0 1 Opower pge elec XXX consumption

Then run the following after replacing the ids with the ones from the previous query:

SELECT * FROM statistics WHERE metadata_id = 85 ORDER BY start_ts DESC LIMIT 10;

SELECT * FROM statistics WHERE metadata_id = 86 ORDER BY start_ts DESC LIMIT 10;

@audiofreak9
Copy link
Author

I use MariaDB so I had to use PHPMyAdmin, hope this text output is good enough...

|604|opower:ace_elec_4001842964_energy_cost|opower|NULL|0|1|Opower ace elec 4001842964 cost |605|opower:ace_elec_4001842964_energy_consumption|opower|kWh|0|1|Opower ace elec 4001842964 consumption

so 604 yields:

|668103|NULL|NULL|NULL|NULL|NULL|NULL|425.47|28915.129999999994|604|1696020848.368874|1693368000|NULL |579616|NULL|NULL|NULL|NULL|NULL|NULL|492.1|28489.659999999993|604|1693704225.9507341|1690516800|NULL |533758|NULL|NULL|NULL|NULL|NULL|NULL|430.09|27997.559999999994|604|1692397728.5801663|1687838400|NULL |533757|NULL|NULL|NULL|NULL|NULL|NULL|352.59|27567.469999999994|604|1692397728.5777245|1685073600|NULL |533756|NULL|NULL|NULL|NULL|NULL|NULL|246.42|27214.879999999994|604|1692397728.5752783|1682481600|NULL |533755|NULL|NULL|NULL|NULL|NULL|NULL|187.34|26968.459999999995|604|1692397728.5735028|1679976000|NULL |533754|NULL|NULL|NULL|NULL|NULL|NULL|239.17|26781.119999999995|604|1692397728.5717719|1677301200|NULL |533753|NULL|NULL|NULL|NULL|NULL|NULL|169.72|26541.949999999997|604|1692397728.5694172|1674795600|NULL |533752|NULL|NULL|NULL|NULL|NULL|NULL|195.27|26372.229999999996|604|1692397728.5669427|1672376400|NULL |533751|NULL|NULL|NULL|NULL|NULL|NULL|350.93|26176.959999999995|604|1692397728.5646255|1669784400|NULL

and 605 yields:

|668104|NULL|NULL|NULL|NULL|NULL|NULL|1865|149118|605|1696020848.3764186|1693368000|NULL |579617|NULL|NULL|NULL|NULL|NULL|NULL|2184|147253|605|1693704225.9606853|1690516800|NULL |533861|NULL|NULL|NULL|NULL|NULL|NULL|1912|145069|605|1692397728.7193213|1687838400|NULL |533860|NULL|NULL|NULL|NULL|NULL|NULL|1599|143157|605|1692397728.7181406|1685073600|NULL |533859|NULL|NULL|NULL|NULL|NULL|NULL|1184|141558|605|1692397728.7170343|1682481600|NULL |533858|NULL|NULL|NULL|NULL|NULL|NULL|898|140374|605|1692397728.7157485|1679976000|NULL |533857|NULL|NULL|NULL|NULL|NULL|NULL|1177|139476|605|1692397728.7144856|1677301200|NULL |533856|NULL|NULL|NULL|NULL|NULL|NULL|828|138299|605|1692397728.7130892|1674795600|NULL |533855|NULL|NULL|NULL|NULL|NULL|NULL|959|137471|605|1692397728.7120464|1672376400|NULL |533854|NULL|NULL|NULL|NULL|NULL|NULL|1742|136512|605|1692397728.711045|1669784400|NULL

@tronikos
Copy link
Contributor

It seems you only have monthly data up to Aug 29, 2023. In the energy dashboard if you change it to the year view you should see data. Not sure yet why it cannot pull more recent data. Can you click on the year view on your screenshot? Do you have bill and day view? Can you run the demo.py of the upstream library at https://github.com/tronikos/opower requesting dates after Aug 29 to try to debug on your own?

@audiofreak9
Copy link
Author

audiofreak9 commented May 17, 2024

I believe my smart meter was installed in August of 2023. I can see day view starting with yesterday. I wonder why my monthly stopped, I’m assuming the integration needs monthly data? I’ve worked for ACE for 23 years, time to make some calls?

I’ll fiddle with demo.py.

@audiofreak9
Copy link
Author

audiofreak9 commented May 17, 2024

Clicking around my account online, my monthly data appears it restarts on September 27th ‘23. So there is a gap, some days are missing and there is a bunch of estimated usage. I guess the first bit of missing data throws the error. What is the query range? 1 year? Thanks!

@tronikos
Copy link
Contributor

The integration doesn't need monthly data. It pulls at whatever resolution the utility supports. The supported ones are: hourly, daily, monthly.

If there is a gap that explains it. Would you mind temporarily changing the password and share with me your username and password to see how to best resolve this? You can privately reach me by gmail, discord, or home assistant community. My username is tronikos in all of them.

@audiofreak9
Copy link
Author

I DM'd you on Home Assistant community

@tronikos tronikos linked a pull request May 20, 2024 that will close this issue
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants