djansen1987/SAJeSolar

Incorrect Reporting of totalGridPower and totalLoadPower in SAJ eSolar Integration

Closed this issue · 4 comments

While debugging the SAJ eSolar custom component, I noticed that the totalGridPower and totalLoadPower metrics are consistently reported as 0.0, which seems incorrect. This issue occurs in the context of fetching data for my solar energy system.

Upon closer inspection through the web interface (via Inspect Element), the actual values for these metrics are shown correctly (e.g., totalGridPower: 2507.0, totalLoadPower: 2507.0 on 2024-03-24 01:40:00). It appears that the integration may not be parsing or handling the data correctly from the API response.

Debug logs show the following for these metrics:

2024-03-24 01:46:05.657 DEBUG (MainThread) [custom_components.saj_esolar.sensor] Device: totalGridPower State: 0.0
2024-03-24 01:46:05.657 DEBUG (MainThread) [custom_components.saj_esolar.sensor] Device: totalLoadPower State: 0.0

However, the API response clearly provides non-zero values:

"totalGridPower": 2507.0,
"totalLoadPower": 2507.0,
...

After upgrading my inverter from the R5 series to the R6 series (R6-20K-T2-32), I continued using the same SAJ Sec Module (M5370G2025XXXXXX). It's possible that this hardware change might be influencing how data is reported or interpreted by the integration, leading to the observed discrepancies in totalGridPower and totalLoadPower metrics.

Including this information will help developers to better understand the potential impact of hardware changes on the integration's functionality.

In the debug log in HA also the complete json is printed. Do you see the values in the json or are they also 0.0 there.
If so, it could be that they have changed their api. Could you also provide the API url where you have found the corrent information?

No response

I think this is what I originally asked around here:
#41

I think there is a confusion on what "totalloadpower" is meant to be.
currently, at least for saj_sec, totalloadpower is taken from column 2 of getPlantMeterChartData.
Looking at the data and website I think column is the "self consumed" energy (i.e. amount of the solar power you are consuming) so at night it will always be zero.

Column 1 has the total consumption of the home (no matter if it comes from grid or panels).
This is consistent with the UI as well:
image

They are easy to confuse becase in certain scenarios they will match (when all your power comes from your panels)

since my first bug didn't reach to any conclusion (at the time it seems I was the only sec user ) I just changed the line by myself, but maybe now it's more clear this is incorrect.

what I did was simply changing the line for totalLoadPower to pick column 1 instead of 2.

 if self._type == 'totalLoadPower':
                    if 'dataCountList' in energy:
                        if energy["getPlantMeterChartData"]['dataCountList'][4][-1] is not None:
                            self._state = float(energy["getPlantMeterChartData"]['dataCountList'][2][-1])

to

 if self._type == 'totalLoadPower':
                    if 'dataCountList' in energy:
                        if energy["getPlantMeterChartData"]['dataCountList'][4][-1] is not None:
                            self._state = float(energy["getPlantMeterChartData"]['dataCountList'][1][-1])

@LowKey88 since this bug is closed, maybe you can checkout my PR at #96 (comment) and see if you think this explains the behaviour? maybe you can try my changes? I only fixed totalLoadPower, but I think I figured out the issue, but I would love some confirmation.