johanmeijer / grott

Growatt inverter monitor
https://github.com/johanmeijer/grott/wiki
374 stars 103 forks source link

Negative temperatures return 65.535-ish #491

Open osos opened 7 months ago

osos commented 7 months ago

I know it is not good, but it seems the temperature for my battery is below zero these days.

The temperature seem however to be treated as an unsigned integer, thus, resulting in temperature read-outs of 65.535-65.533 . Tempertures should simply be signed int16. if treated as signed int32 it will still fail

osos commented 7 months ago

I suggest import numpy as np and the change of this line: https://github.com/johanmeijer/grott/blob/eafd8f11da54119b89159c5f0fb7a533f068fc6a/grottdata.py#L247

to:

int_value = int(
                            result_string[
                                conf.recorddict[layout][keyword][
                                    "value"
                                ] : conf.recorddict[layout][keyword]["value"]
                                + (conf.recorddict[layout][keyword]["length"] * 2)
                            ],
                            16,
                        )
                        if conf.recorddict[layout][keyword]["length"] < 4:
                            definedkey[keyword] = int(np.int16(int_value))
                        else:
                            definedkey[keyword] = int(np.int32(int_value))

this should handle both the 16 and 32 bit values with correct sign

johanmeijer commented 7 months ago

Do you have a growatt original record from the grott log for me so I can test it?

osos commented 6 months ago

I realised that I just need to the type of battemp, and other temperatures to 'numx' instead of 'num'.

Running for a few days now with the numx setting and seem to convert correctly.

Thus, I suggest the temperatures are by default set to numx types.

This layout was tested: examples/Record Layout/t06NNNNXSPH.json

johanmeijer commented 6 months ago

Thanks for the solution. That is what I want to try also. I will update this in a next release.

mariano-dagostino commented 6 months ago

I would like to add to this issue some other examples of values with problems:

I have an offgrid inverter that is using the layout T060104SPF

I've seen the values for

My understanding is the inverter is simply sending -1 (maybe due some internal failure, not sure) and the number is converted to the highest value allowed 65535 (2^16) and 4294967295 (2^32).

Screenshot_2023-12-14_15-12-46

I'm not really sure what is the best path of action here... IMO the value shouldn't be included in the response so home assistant would render it as undefined...

Thanks for this amazing project btw!

johanmeijer commented 6 months ago

@mariano-dagostino Do you have th eoriginal data from the inverter/datalogger when this happens? I can then test with it (and change it).

mariano-dagostino commented 6 months ago

Do you have th eoriginal data from the inverter/datalogger when this happens? I can then test with it (and change it).

@johanmeijer Actually I haven't seen this behavior in a week so far. I think this was caused because I didn't configured the inverter type to be ginvtype=spf when I started playing with grott.

joris-weijters commented 4 months ago

I have a similar issue with GROTT 2.8.3 with my inverter MOD 5kTL3-XH Just at the end of the day, I think when the grot shutdown, I get a 429.496.729,5 ( 2ˆ32 -1 ) Watt value for the sensor._output_power ( pvpowerout )

I configured my Inverter like as a MIN. It looks like at the time of shutdown the inverter sends a -1 value ( FFFF FFFF ).

I see in the grottconf.py for the T06NNNNXMIN" it is a "num" ( unsigned integer ) for the others it is a numx ( signed integer )

johanmeijer commented 3 months ago

I do not think that it hurts to configure this a numx field.

I am building a new version of Grott. I will review and try to test if the num fields can be changed to numx (supporting negative values). I am not sure if I can change al fields.

joris-weijters commented 3 months ago

@johanmeijer,

I created a PR for the issue with the negative pvpowerout, https://github.com/johanmeijer/grott/pull/527