tijsverkoyen / HomeAssistant-FusionSolar

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

Division by zero #80

Closed perezga closed 1 year ago

perezga commented 1 year ago

I have 3 optimizers, an inverter and a power sensor entitiies found by the integration, but only 1 of the optimizers entities is showing data, the rest of entities are just not even displayed when I try to add them in the dashboard.

The error I see in the HASS log is the one I pasted below.

Logger: custom_components.fusion_solar.device_real_kpi_coordinator Source: custom_components/fusion_solar/device_real_kpi_coordinator.py:47 Integration: FusionSolar (documentation, issues) First occurred: 22:04:01 (1 occurrences) Last logged: 22:04:01

Unexpected error fetching FusionSolarOpenAPIDeviceRealKpiType data: integer division or modulo by zero Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/fusion_solar/device_real_kpi_coordinator.py", line 47, in _async_update_data index_to_fetch = self.counter % len(device_ids_grouped_per_type_id) ZeroDivisionError: integer division or modulo by zero


Also note the API requests is actually showing data in the response when requesting to getDevRealKpi for the inverter and the power sensor, but when asking the API to get data for the optimizers it returns empty in the dataItemMap as you can see below. That cannot be because of rights, because as mentioned above, when trying to configure the fusion solar integration, it actually returns data for 1 of the optimizers only which is very confussing....using the API it returns data for all but optimizers....Using the HASS integration only shows data for 1 of the optimizers and nothing for the rest of entities and instead it shows the division by zero error. I guess that should be easy to debug if you know the code...Maybe a new parameter was added or the data format of one of them is now different and causing the script to stop working as it finds that error. { "data": [ { "devId": ZZZZ, "dataItemMap": {}, "sn": "null" }, { "devId": YYYY, "dataItemMap": {}, "sn": "null" }, { "devId": XXXXX, "dataItemMap": {}, "sn": "null" } ], "failCode": 0, "message": null, "params": { "currentTime": 1679433191233, "devIds": "XXXX, YYYY, ZZZZ", "devTypeId": 46 }, "success": true }


perezga commented 1 year ago

Now, all of a sudden, the 3 optimizers entities are showing data in HASS. Still same empty dataitemmap when using the API directly through postman which makes not much sense, to be honest...

perezga commented 1 year ago

I didnñt noticed I had another FUsion SOlar integration hidden so probably that was causing the wrong data....once both solar fusion integrations were deleted and reinstaled again, everything shows as expected, so closing.