tijsverkoyen / HomeAssistant-FusionSolar

Integrate FusionSolar into your Home Assistant.
MIT License
149 stars 27 forks source link

Huawei API changes ? #98

Closed treepleks closed 1 year ago

treepleks commented 1 year ago

For one or two weeks now, the integration is essentially failing here, but only half way. It does connect (it retrieves all the "Diagnostic" info, name and id of the station,...) but collects no information on the plant itself, all sensors are marked as unavailable.

Activating the log, I see a strange mixture of errors (Invalid access to current interface! (success: False)) and success (JSON data for https://eu5.fusionsolar.huawei.com/thirdData/getStationRealKpi: [...] success': True).

Everything was working fine previously. I tried to,restart the integration with no result. If I can help more than this, just tell me.

2023-06-24 14:11:29.302 DEBUG (SyncWorker_3) [custom_components.fusion_solar.fusion_solar.openapi.openapi_api] JSON data for https://eu5.fusionsolar.huawei.com/thirdData/getKpiStationYear: {'data': None, 'failCode': 401, 'message': 'Invalid access to current interface!', 'params': {}, 'success': False}
2023-06-24 14:11:29.306 ERROR (MainThread) [custom_components.fusion_solar.sensor] Unexpected error fetching FusionSolarOpenAPIStationYearKpi data: Invalid access to current interface!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 242, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fusion_solar/sensor.py", line 656, in async_update_station_year_kpi_data
    response = await hass.async_add_executor_job(api.get_kpi_station_year, station_codes)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fusion_solar/fusion_solar/openapi/openapi_api.py", line 122, in get_kpi_station_year
    response = self._do_call(url, json)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fusion_solar/fusion_solar/openapi/openapi_api.py", line 183, in _do_call
    raise FusionSolarOpenApiErrorInvalidAccessToCurrentInterfaceError(json_data[ATTR_MESSAGE])
custom_components.fusion_solar.fusion_solar.openapi.openapi_api.FusionSolarOpenApiErrorInvalidAccessToCurrentInterfaceError: Invalid access to current interface!
2023-06-24 14:11:29.311 DEBUG (MainThread) [custom_components.fusion_solar.sensor] Finished fetching FusionSolarOpenAPIStationYearKpi data in 0.215 seconds (success: False)
2023-06-24 14:11:29.326 DEBUG (SyncWorker_8) [custom_components.fusion_solar.fusion_solar.openapi.openapi_api] JSON data for https://eu5.fusionsolar.huawei.com/thirdData/getStationRealKpi: {'data': [{'stationCode': 'XXXXXXXXXXXXXXXXXXXXXXXX', 'dataItemMap': {'total_income': 0.0, 'total_power': 22962.91, 'day_power': 6.9, 'day_income': 0.0, 'real_health_state': 3, 'month_power': 257.73}}], 'failCode': 0, 'message': None, 'params': {'currentTime': 1687608689312, 'stationCodes': 'XXXXXXXXXXXXXXXXXXXXXXXX'}, 'success': True}
tijsverkoyen commented 1 year ago

@treepleks Are you willing to share your credentials with me? As I don't have this issue, it would really help me to use your credentials to debug (and fix) this issue. You can mail your credentials to fusionsolar [at] verkoyen.eu

gorsehill commented 1 year ago

My integration just stopped all of a sudden nearly 2 weeks ago too. I am pretty sure there was scheduled Huawei maintenance around then.

treepleks commented 1 year ago

Dear Tijs, Sorry for the lag. Will have a look and contact you using the email address above. Thanks for looking into this!

treepleks commented 1 year ago

Before contacting you, I logged again in the Huawei installer account to check all permissions. To my surprise several - but not all - of the required permissions were OFF (I had enabled them several months ago, as indicated in the extension's page and the extension worked flawlessly) . I turned them on again and restarted HA. The extension works again ! Sorry for bugging you for nothing (I don't understand this mess, I imagine Huawei did something).

tijsverkoyen commented 1 year ago

Glad it works