tijsverkoyen / HomeAssistant-FusionSolar

Integrate FusionSolar into your Home Assistant.
MIT License
133 stars 25 forks source link

Lifetime energy does not recover after Kiosk max retries. #155

Closed AndersHoglund closed 3 months ago

AndersHoglund commented 4 months ago

Hi,

New (?) kiosk behaviour from Huawei at midnight. Max retries occurs. All entities recover after a while, except total_lifetime_energy. Need to restart HA to get things going again. Log cut out:

2024-03-05 00:02:59.892 ERROR (MainThread) [custom_components.fusion_solar.sensor] Error requesting FusionSolarKiosk data: HTTPSConnectionPool(host='uni002eu5.fusionsolar.huawei.com', port=443): Max retries exceeded with url: /rest/pvms/web/kiosk/v1/station-kiosk-file?kk=Jrlxxxxxxxxxxxxxxxxxxax (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f64a64e60>: Failed to establish a new connection: [Errno -3] Try again'))

All this seems to have starte 1:st of March. Did not notice until yesterday that there was no lifetime_energy data, restarted HA and it all came alive again. Same issue today, restart HA to get it going. Sorry, no debug log was running at those times

Will try to have a fresh debug log running at midnight tonight. /A
total_lifetime_energy_fail

AndersHoglund commented 4 months ago

No problems last night. Nothing new in the logs. Typical, when you start logging, no problems. Will keep an eye on this.

But i did look back in history to the first time I noticed this happening, Jan 29. So now we have at least two records of this happening. /A

Screenshot 2024-02-29 History – Home Assistant
AndersHoglund commented 3 months ago

Happened again last night, twice. And of course, I had no debug logging running at that time.

2024-03-08 00:00:56.613 ERROR (MainThread) [custom_components.fusion_solar.sensor] Error requesting FusionSolarKiosk data: HTTPSConnectionPool(host='uni002eu5.fusionsolar.huawei.com', port=443): Max retries exceeded with url: /rest/pvms/web/kiosk/v1/station-kiosk-file?kk=JrlNJcLJ3daMl24aN4F45PIiLxw36xax (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f70818650>: Failed to establish a new connection: [Errno -3] Try again'))

2024-03-08 01:51:41.614 ERROR (MainThread) [custom_components.fusion_solar.sensor] Error requesting FusionSolarKiosk data: HTTPSConnectionPool(host='uni002eu5.fusionsolar.huawei.com', port=443): Max retries exceeded with url: /rest/pvms/web/kiosk/v1/station-kiosk-file?kk=JrlNJcLJ3daMl24aN4F45PIiLxw36xax (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f762b93a0>: Failed to establish a new connection: [Errno -3] Try again'))

All entities seem to recover, except Lifetime energy:

Screenshot 2024-03-08 at 09-10-26 Huawei VR – Home Assistant

Turned on debug this morning to see what the data from Huawei looks like:

2024-03-08 09:11:41.917 DEBUG (SyncWorker_47) [custom_components.fusion_solar.fusion_solar.kiosk.kiosk_api] {'realTimePower': 4.193, 'cumulativeEnergy': 25062.17, 'monthEnergy': 125.15, 'dailyEnergy': 4.54, 'yearEnergy': 426.98}
2024-03-08 09:11:41.923 DEBUG (MainThread) [custom_components.fusion_solar.sensor] Finished fetching FusionSolarKiosk data in 0.323 seconds (success: True)
2024-03-08 09:11:41.924 INFO (MainThread) [custom_components.fusion_solar.fusion_solar.energy_sensor] sensor.kronkarrs_huawei_vr_jrlxxxxxxxxxxxxxxxxxx36xax_total_lifetime_energy: not available, so no update to prevent issues.

Cumulative Energy data from Huawei seems OK, but this integration returns nothing (or "not available" or "Unknown"). Can it be the glitch filter locking up? Rebooting HA fixes this. /A

tijsverkoyen commented 3 months ago

¯_(ツ)_/¯ I really am thinking about to just remove all code related to handling API errors and just passing data that is received from Huawei

AndersHoglund commented 3 months ago

Yeah, I understand your frustration. Same here. Giving up trying to hide the Huawei crap data is one way.....But please, give it one more chance. Maybe my initial "fix" using a global would work better? I could give that a try. Or just make fewer kiosk accesses. 10min interval when Huawei updates only every 30min is a bit of a waste, 15min polling might be enough. From 144 to 96 times a day. Not sure what the Kiosk limit is. Where do I change this time interval? /A

tijsverkoyen commented 3 months ago

https://github.com/tijsverkoyen/HomeAssistant-FusionSolar/blob/master/custom_components/fusion_solar/sensor.py#L91

AndersHoglund commented 3 months ago

Thnx. I increased access rate to once every minute, to provoke failure. Added some debug logging in energy_sensor.py to see what kind of state data we deal with when it fails.

            if entity is not None:
                _LOGGER.debug(f'{self.entity_id} State: {entity.state}')
                try:
                    current_value = float(entity.state)
                except ValueError:
                    _LOGGER.info(f'{self.entity_id}: not available, so no update to prevent issues.')
                    return

Nothing in the log as yet. /A

AndersHoglund commented 3 months ago

Been logging all day yesterday and all night at 60s rate and no problems seen. Will revert to 10min rate and keep logging. /A

tijsverkoyen commented 3 months ago

Any update? Or can this issue be closed?

AndersHoglund commented 3 months ago

No incident has occurred since last report, even when trying to provoke. But this code can still lock up and require restart in some situations, so it is still a lurking problem.

Close if you wish, I can re-open if and when it happens again. Actually, closing the issue may jinx it and provoke a failure ;-) /A

AndersHoglund commented 2 months ago

Again last night:

2024-04-08 22:50:51.441 ERROR (MainThread) [homeassistant.components.hassio.data] Error fetching hassio data: Error on Supervisor API: System is not ready with state: setup 2024-04-08 22:51:07.164 ERROR (MainThread) [metno] Access to https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/2.0/complete returned error 'ClientConnectorError' 2024-04-08 22:51:07.165 ERROR (MainThread) [homeassistant.components.met.coordinator] Error fetching met data: Update failed: 2024-04-08 22:51:07.227 ERROR (MainThread) [custom_components.fusion_solar.sensor] Error requesting FusionSolarKiosk data: HTTPSConnectionPool(host='uni002eu5.fusionsolar.huawei.com', port=443): Max retries exceeded with url: /rest/pvms/web/kiosk/v1/station-kiosk-file?kk=JrlNJcLJ3daMl24aN4F45PIiLxw36xax (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5e600b90>: Failed to establish a new connection: [Errno -3] Try again'))