tijsverkoyen / HomeAssistant-FusionSolar

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

Cannot get data #106

Closed stefanofalasca closed 10 months ago

stefanofalasca commented 10 months ago

I configured component to use Open Api. I am not installer but with my user and password I see all plants of installer zone, so I disabled all devices and I enabled only my device. The problem is that data of my device are not updated. Looking log see follow error.

ERROR (MainThread) [custom_components.fusion_solar.sensor] Unexpected error fetching FusionSolarOpenAPIStationRealKpi data: Retrieving the data for https://eu5.fusionsolar.huawei.com/thirdData/getStationRealKpi failed with failCode: 20015, message: None 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 581, in async_update_station_real_kpi_data response = await hass.async_add_executor_job(api.get_station_real_kpi, 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 108, in get_station_real_kpi response = self._do_call(url, json) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/fusion_solar/fusion_solar/openapi/openapi_api.py", line 194, in _do_call raise FusionSolarOpenApiError( custom_components.fusion_solar.fusion_solar.openapi.openapi_api.FusionSolarOpenApiError: Retrieving the data for https://eu5.fusionsolar.huawei.com/thirdData/getStationRealKpi failed with failCode: 20015, message: None 2023-08-24 01:10:44.151 ERROR (MainThread) [custom_components.fusion_solar.sensor] Unexpected error fetching FusionSolarOpenAPIStationYearKpi data: Retrieving the data for https://eu5.fusionsolar.huawei.com/thirdData/getKpiStationYear failed with failCode: 20015, message: None

stefanofalasca commented 10 months ago

A fews entities work, related to general info station, like station address, station code, Station Name, Contact Phone, Capacity and Contact Person, all other entities doesn't work

tijsverkoyen commented 10 months ago

Unexpected error fetching FusionSolarOpenAPIStationYearKpi data: Retrieving the data for https://eu5.fusionsolar.huawei.com/thirdData/getKpiStationYear failed with failCode: **20015**, message: None

If I have a look at the documentation in section 8 Error Code List, it states that failCode 20015 is:

A maximum of 100 plants can be queried at a time.

My first guess is that your installer has given you access to all plants and not your own plant. Ask your installer to create the correct account.

stefanofalasca commented 10 months ago

open api account was created for me by Huawei based on my setup (in theory). However, I have disabled all plants except mine, so I expect the queries you generate to be only for the enabled plant. Does this check?

tijsverkoyen commented 10 months ago

@stefanofalasca if all plants are returned it will do requests for all plants. There is no way for me to check to which plants you have access. The failCode is the raw response from the API

stefanofalasca commented 10 months ago

I want say that you can get data only for devices enabled. I disabled all devices and I enabled only mine

tijsverkoyen commented 10 months ago

Where did you disabled the devices? In Home Assistant? The code gets the data for all plants returned from the FusionSolar API

stefanofalasca commented 10 months ago

Is right from HA, if I disable device, should be correct disable download data for the specific device too. Is possible implement this functionality ?

tijsverkoyen commented 10 months ago

@stefanofalasca I think the changes in https://github.com/tijsverkoyen/HomeAssistant-FusionSolar/pull/107 should fix your issue. Can you apply these changes manually and test? If it works I will create a new release with this included.

Note that you will need to restart your Home Assistant instance after applying the changes.

stefanofalasca commented 10 months ago

@tijsverkoyen I tried work. Great thanks