wills106 / homeassistant-solax-modbus

SolaX Power Modbus custom_component for Home Assistant (Supports some AlphaESS, Growatt, Sofar, Solinteg, Solis, SRNE, Swatten)
317 stars 101 forks source link

[FR] - Improve data for Growatt Inverter's #471

Closed choenig closed 1 year ago

choenig commented 1 year ago

Hi,

I don't know if this should rather be a discussion or an issue, I just post it here as I guess there are more people reading here :)

I have successfully integrated my Growatt SPH 10000TL3 BH-UP Inverter.

The serial starts with 'YA1' so i added

elif seriesnumber.startswith('YA1'):  invertertype = HYBRID | GEN | X3 # Hybrid SPH 4kW - 10kW 3P TL3 BH-UP

to get it running.

Now I already improved some of the configuration values in plugin_growatt.py to enhance descriptions, scales and I also added some more registers. I also reduced the block_size to 64, that fixed some of the received registers.

In any case I'm willing to share my improvements, but it would be really nice to find other users of the SPH TL3 BH-UP inverters to check some values, that look really broken on my setup.

Br Christian

wills106 commented 1 year ago

Feel free to submit any improvements either through comment's or PR's.

Unfortunately the Growatt Inverters are a little unloved at the moment as there aren't many users. Also the growatt_plugin hasn't been fully setup for PV only Inverters which I need to work on.

Hans-chr2 commented 1 year ago

Hi Christian

What changes did you make ? last i tried the mapping for the TL3-BH-UP were wrong.

I have a same inverter as you, just 8kW model, if you have done some mapping i could verify some of them on mine.

wills106 commented 1 year ago

Just released 2023.07.2 which has Firmware starting 'YA1'

Hans-chr2 commented 1 year ago

I finds the inverter now, nut the mapping seems to be off. billede billede billede

wills106 commented 1 year ago

This is the first time a 3Phase Inverter using this set of registers has been used on the Integration. I'll need to go back over the documents.

Hans-chr2 commented 1 year ago

I don't know if this helps

https://pastebin.com/XP9kmvRA

I have the manual in PDF somewhere,... https://www.scribd.com/document/592776725/Growatt-Inverter-Modbus-RTU-Protocol-II-V1-24-English-new

choenig commented 1 year ago

Hi, juchu a buddy :)

I just created a WIP-pullrequest https://github.com/wills106/homeassistant-solax-modbus/pull/473 that shows what I changed.

@Hans-chr2 Some of your above errors will get fixed by my changes (e.g. the last two values). Those get fixed by reducing the block_size to 64, don't know why :)

Values for L2 and L3 look broken here, too, but L1 is mostly correct (just as if it was just a 1 phase inverter)

choenig commented 1 year ago

This is my state:

2023-07-23 14 25 28 ha spsx casa 7c83e412a34b 2023-07-23 14 25 46 ha spsx casa 02cb52bbe9d3 2023-07-23 14 25 58 ha spsx casa 127818359d69 2023-07-23 14 26 15 ha spsx casa ec940d7cea80 2023-07-23 14 26 26 ha spsx casa 9e85bef64726

choenig commented 1 year ago

Hi,

I just updated the PR.

I switched back to 100 regs/fetch as I found out, that the issue was just a duplicate reg in the configuration. That resulted in misalignments when assigning values (as it is handled as "set of byte values" then).

Now I don't have any errors in the log anymore during fetch :).

I added some more registers but they don't make too much sense to me.

@Hans-chr2 Did you have a chance to test my patch?

Br Christian

Hans-chr2 commented 1 year ago

How do i test your patch easy ?

choenig commented 1 year ago

This is the link to the file of the PR:

https://raw.githubusercontent.com/wills106/homeassistant-solax-modbus/32728ab222979ada4f832e99de326976d13c19e3/custom_components/solax_modbus/plugin_growatt.py

You can download it and replace ./custom_components/solax_modbus/plugin_growatt.py with the downloaded one. Then you need to restart HA (quick restart is not enough). I'd suggest to create a copy of the original file before overwriting it ... just in case ;-)

The next official update (done via HACS) will overwrite the file again.

Hans-chr2 commented 1 year ago

Just a quick overlook, the following are off: billede billede

Hans-chr2 commented 1 year ago

The power reading seems to be the only sensors that are off, but i just looked over it quickly. When i look at the code, you use: billede

and i use: billede

as stated in the PDF i'm pretty sure all power readings are int32 and there are high power [kW] reading and low [W] billede

wills106 commented 1 year ago

I'm pretty sure all power readings are int32

That's correct if the register is bidirectional it needs to be an int so it can represent positive and negative values.

You will find that positive means import from the grid and negative is exporting to the grid. (Or the other way round)

@choenig once you are happy with the PR let me know and I can merge it.

Hans-chr2 commented 1 year ago

@wills106 i know, but as i see it the registers are U32 and if that is correct what ChatGPT states, then you will get some very low or very high power readings because the first bit is used to determine positive/negative.

But i don't know how the change the int type from U32 til int32, i tried it briefly last night but no luck.

choenig commented 1 year ago

Using signed ints here makes absolute sense, unfortunately the values are still off for me.

The raw data for 1031, 1033 and 1035 (House Load L1-L3) looks like this:

Screenshot 2023-07-26 at 09 54 03

And here for 1023, 1025, 1027 and 1029 (AC Power to Grid L1-L3 and Total)

Screenshot 2023-07-26 at 09 58 53

That does not look like signed ;)

Any other idea?

@wills106 Thanks, I think i'm trying to get these things sorted out, then I'll make it ready for you :)

Hans-chr2 commented 1 year ago

@choenig i can't find the modbus manual 1,24 from Growatt on my computer anymore. If you can find that manual you can see the data size. As i remember all power and energy readings are 32 bit, and i can see on your screen dump above you pull 16 bit.

choenig commented 1 year ago

I have the manual here, but where does it say something about signed/unsigned? I only find the information if it is high 16bit and low 16bit like here:

Screenshot 2023-07-26 at 16 58 16

Or am I missing someting?

As i remember all power and energy readings are 32 bit, and i can see on your screen dump above you pull 16 bit.

That's correct, but each 32bit field contains of two 16bit fields. E.g. for 1035 and 1036: If we combine 214 (two high bytes) and 226 (two low bytes) we get a strange high number. Or is there any advanced way to combine those two values?

and i use:

[From the previous post] Do you have a running application that displays those value correctly?

wills106 commented 1 year ago

If you use GModbus you have the option to read registers as 32bit either a normal number or as a float.

So you would only read: 1031 as "unit = REGISTER_U32," or "unit = REGISTER_S32," 1033 as "unit = REGISTER_U32," or "unit = REGISTER_S32," 1035 as "unit = REGISTER_U32," or "unit = REGISTER_S32,"

Depending on which method you need. Pymodbus will read the inbetween registers as part of each 32bit read (reads two 16bit registers to create a 32bit one)

Hans-chr2 commented 1 year ago

When i use the modbus integration in Home Assistant via the config files i only use the int32 bit, the power values can both be negative and positive. i also don't read multiple registers only 1 addressee at the time.

I think we either over complicates things, or there is something i have done that is stupidly lucky in the config. :-D

billede

Hans-chr2 commented 1 year ago

Im out of options now...

billede

wills106 commented 1 year ago

Im out of options now...

Does House Load L1 & L2 seem correct? It might be possible there is a Firmware fault with L3?

choenig commented 1 year ago

L1 shows the same as Total for me, so I guess L2 and L3 are both broken.

Hans-chr2 commented 1 year ago

billede billede

Regarding L1+L2+L3 i also have the same issue with my generic modbus, so i see the same as @choenig now.

choenig commented 1 year ago

I marked the PR as ready, as it does not look that we have something new here, now.

Let's then see what the holding-registers-side has for us :)

wills106 commented 1 year ago

Just released 2023.07.4b2 with the changes.

wills106 commented 1 year ago

I have just released 2023.07.4b6 which redefines all Growatt Inverters. So a lot has changed.

choenig commented 1 year ago

I just updated to b7 and I have not found any issues, yet :)

wills106 commented 1 year ago

There is an error but I have just released 2023.07.4b8 I was accidentally reading 'Grid Export Limit' as a 32bit register.

wills106 commented 1 year ago

Corrected another error in 2023.07.4b9

wills106 commented 1 year ago

Does anyone with a TL-HX have a 2nd battery system connected to your Inverter?

wills106 commented 1 year ago

Just released 2023.08.2 which fixes an issue with TL-HX / TL3-HX and adds additional sensor entities for TL-HX / TL3-HX Inverters.

wills106 commented 1 year ago

Can this be closed down now? Or is further work required?

wills106 commented 1 year ago

Closing down as no further response.