tronikos / opower

A Python library for getting historical and forecasted usage/cost from utilities that use opower.com such as PG&E
Apache License 2.0
53 stars 49 forks source link

After upgrading to Home Assistant OS 11.1 no more OPower sensors #53

Closed mkanet closed 8 months ago

mkanet commented 8 months ago

I just upgraded to Home Assistant 11.1, after it rebooted, I noticed that all the entities provided by this integration show as Unavailable in red font. I removed the integration and added it again, this time it didn't create any sensors.

I'm not sure if this is because something changed in Home Assistant or the PGE API endpoint is down currently.

tronikos commented 8 months ago

Is that PGE or PG&E? Works fine on my end with PG&E after the upgrade. Sensors are not added if there is no forecast data. Do you see a bill forecast at https://pge.opower.com/ei/x/dashboard ? The important ones are the statistics that you need to add to the energy dashboard. You are not supposed to add the sensors. See https://www.home-assistant.io/integrations/opower/

mkanet commented 8 months ago

@tronikos thank you for replying. It appears the issue was related to the billing period ending. The issue corrected itself automatically approximately 48 hours after this issue started.

Originally, the first symptom I noticed was all the sensors showing as unavailable in Home Assistant. This happened after upgrading to the latest Home Assistant OS version 11.1. At that time, I confirmed that I could still log into PG&E's webpage. I also noticed my billing cycle had just ended. After installing the integration again, all the sensors were missing.

Is this expected behavior right when the billing cycle ends? Is there anything I could have done differently to mitigate the issue?

tronikos commented 8 months ago

I don't think the sensors show unavailable in the beginning of the billing period. I remember only the forecasted usage/cost would be missing from the response so in the code I had to set the default value to 0 for these sensors. See also the note in the documentation "(for the first few days of the bill this is 0)" Maybe this behavior changed. I'll see what happens when my billing period ends/starts.

mkanet commented 8 months ago

I don't think the sensors show unavailable in the beginning of the billing period. I remember only the forecasted usage/cost would be missing from the response so in the code I had to set the default value to 0 for these sensors. See also the note in the documentation "(for the first few days of the bill this is 0)" Maybe this behavior changed. I'll see what happens when my billing period ends/starts.

Sounds good. Maybe I shouldn't have done anything when I saw all the sensors turn into Unavailable. Maybe it was a coincidence it happens exactly at the same time my billing ended.

mkanet commented 8 months ago

I don't think the sensors show unavailable in the beginning of the billing period. I remember only the forecasted usage/cost would be missing from the response so in the code I had to set the default value to 0 for these sensors. See also the note in the documentation "(for the first few days of the bill this is 0)" Maybe this behavior changed. I'll see what happens when my billing period ends/starts.

It happened again after restarting Home Assistant Core. I didn't change anything related to this integration; I only rebooted the HA Core. I have full internet access and all other Internet-sensitive HA integrations still work correctly except for OPower.

image image image

I'm not going to make the same mistake of deleting the integration. However, I'm not sure how to force it to work correctly again. Please let me know.

tronikos commented 8 months ago

Can you click on "enable debug logging" in your 1st screenshot? And then click on the 3 dots and reload

mkanet commented 8 months ago

@tronikos about 5 minutes after I had posted this, I noticed that everything returned back to a working state without me doing anything.. not even rebooting.

I just enabled debug logging in the Opower integration. However, currently it is working.

QUESTION: Is this Integration smart enough to use the last known sensor values when the API endpoint becomes unavailable? Hopefully, there's a way to avoid this from happening.

QUESTION2: I noticed that this issue happens immediately after a reboot. Is it possible that it takes several minutes sometimes for the Opower integration to startup? The reason I ask is because I noticed the following in my log after rebooting 👍

2023-10-31 13:27:24.698 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Pacific Gas and Electric Company (PG&E) (mkanet)' for opower integration not ready yet: Cannot connect to host itiamping.cloud.pge.com:443 ssl:default [Try again]; Retrying in background
tronikos commented 8 months ago

I restarted and I got the same error.

Running nslookup itiamping.cloud.pge.com from a terminal inside HAOS I get SERVFAIL. From my laptop it succeeds. Not sure what's going on. Either a temporary issue with pge or a HAOS issue.

mkanet commented 8 months ago

Thanks for checking. Do you think there is a way to accommodate this case by having the Opower integration revert to the last valid sensor value if the endpoint is not reachable from HAOS? Or, do you think that would be a bad idea?

tronikos commented 8 months ago

My bill started yesterday and I encountered the same. This was a regression when I submitted https://github.com/tronikos/opower/commit/57a62f2de8e8339f64249e2c82a8cee306ede48f 2 months ago. Fixed in https://github.com/tronikos/opower/commit/d375e3e41fe24409991c15fd2ff63231f54c5ac8

mkanet commented 8 months ago

Thank you!

dave-parsons commented 5 months ago

I'm observing this same behavior again after upgrading to HA 2024.1.4. Manual install of HACS version fixes it..