mvandersteen / SungrowInverter

Allows to pull data from a Sungrow residential inverter via Modbus TCP
Other
26 stars 16 forks source link

Division by zero error early in day when pv generation is zero #6

Closed smnrgrs closed 1 year ago

smnrgrs commented 1 year ago

I think I'm seeing a division by zero error from Line 149 of Hybrid.py early in the day before there's been any generation. As eval() only takes simple expressions a fix may be to add a small quantity to daily_pv_generation, e.g. 0.001

mvandersteen commented 1 year ago

Wrapped in a try catch now, and outputs 0 if an error occurs should be resolved for next release. Just working through issue with Modbus updates at the moment.

smnrgrs commented 1 year ago

Thanks!

mvandersteen commented 1 year ago

Fixed in release 0.2.0

smnrgrs commented 1 year ago

Is there any way to force HA to update- still suffering this big. I'm trying editting the min version in the manifest file

Octofinger commented 1 year ago

I think I found an issue with that fix. The eval of calculated registers is only followed by a finally that always set the result to zero. Instead you should catch ZeroDivisionError and then set the result to zero. Skip the finally clause entirely.

tinywiz commented 6 months ago

Any update on this issue? Having the same problem. Happens as soon as the daily pv generation is 0. When time pass midnight (00:00) the dev by 0 occurs. And works again as soon as daily_pv_generation is 0.100

smnrgrs commented 6 months ago

I also still have the issue. If I could modify the running SungrowInverter python script on my HA pi I could probably find a fix, but I can't find where the libraries are.

tinywiz commented 6 months ago

I also still have the issue. If I could modify the running SungrowInverter python script on my HA pi I could probably find a fix, but I can't find where the libraries are.

I decided to run it locally on a n ubuntu server, modified the code and it works now :)

smnrgrs commented 6 months ago

Great, would you be able to summit a pull request?

tinywiz commented 6 months ago

Great, would you be able to summit a pull request?

Ok, managed to make a pull request :)

If it doesn't get merged, you could always use the fork I suppose?

https://github.com/tinywiz/SungrowInverter