wlcrs / huawei_solar

Home Assistant integration for Huawei Solar inverters via Modbus
GNU Affero General Public License v3.0
560 stars 90 forks source link

[Bug]: Abnormal value for "Battery Total charge" #856

Closed JensenNick closed 4 hours ago

JensenNick commented 5 days ago

Describe the issue

I'm getting an very abnormal initial reading of the value for ´sensor.batteries_total_charge´ . The reading currently id about 463 MWh which of course isn't correct. I also se a smal deviation of the reading for ´sensor.batteries_total_discharge´. Here are the readings I get in the Huawei Solar integration and the values I have in the FusionSolar app.

The issue is also described in this discussion https://github.com/wlcrs/huawei_solar/discussions/628

2024-11-24_14-11-58

I have created a new instance of Home Assistant with a new install og the Huawei Solar integration. In order to get the initial value included in the debug log I have proceeded with these steps.

  1. Installed the Huawei Solar integration
  2. Enabled debug logging
  3. Reconfigured the integration
  4. Downloaded the debug log named "…145Z.log"

In order to "track" the reading of the modbus data from the battery I have logged the discharged and charged of the battery.

  1. Set up TOU to discharge from 13:32 until 13:42 and to charge from 13:45 to 13:50.
  2. Enabled debug logging
  3. Downloaded the debug log named "…270Z.log"

Included are also relevant exports from the sql-database as csv-files in order to track the values.

Describe your Huawei Solar Setup

Inverter #1 Type: Huawei SUN2000 10KTL-M1 Inverter #1 Firmware version: V100R001C00SPC165 Inverter #2 Type: Huawei SUN2000 3KTL-L1 Inverter #2 Firmware version: V200R001C00SPC142 sDongle present: Yes sDongle Type: sDongleA-05 (WiFi / Ethernet) sDongle Connectivitiy: Ethernet sDongle Firmware: V200R022C10SPC121 Power meter present: three phase Optimizers Present: No Battery: LUNA2000-S1 10kWh Battery Firmware version: V100R002C00SPC624 Huawei Solar integration version: 1.5.0a1

How do you connect to the inverter?

Please select your connection method

Upload your Diagnostics File

Drag & Drop your Diagnostics File here. config_entry-huawei_solar-01JDF1SV35W5S3HFZ4PFK720ZP.json

home-assistant_huawei_solar_2024-11-24T12-26-27.145Z.log

home-assistant_huawei_solar_2024-11-24T12-57-02.270Z.log

states_total_charge_2024-11-24_14-34.csv

states_total_discharge_2024-11-24_14-35.csv

states_batteries_charge_discharge_2024-11-24_14-37.csv

Upload your relevant debug logs

Getting an error trying to copy/past the log here and I don't have an option to attach a file.

Please confirm the following:

wlcrs commented 4 days ago

The total charge is stored in registers 37780 and 37781. We retrieve this by reading 28 registers, starting from register 37760.

2024-11-24 13:25:13.783 DEBUG (MainThread) [huawei_solar.huawei_solar] Reading register 37760 with length 28 from slave 1 2024-11-24 13:25:13.784 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x61 0x0 0x0 0x0 0x6 0x1 0x3 0x93 0x80 0x0 0x1c 2024-11-24 13:25:13.791 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x61 0x0 0x0 0x0 0x3b 0x1 0x3 0x38 0x3 0xca 0x0 0x0 0x0 0x2 0x1b 0x16 0x0 0x0 0xff 0xff 0xff 0xee 0x0 0x0 0x27 0x10 0x0 0x0 0x27 0x10 0x0 0x0 0x27 0x10 0x0 0x0 0x27 0x10 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x2 0xc2 0xf9 0x34 0x0 0x8 0x89 0x65 0x0 0x0 0x2 0xa4 0x0 0x0 0x0 0x1e old_data: addr=None

Register Hex value
37760 0x3 0xca
37761 0x0 0x0
37762 0x0 0x2
37763 0x1b 0x16
37764 0x0 0x0
37765 0xff 0xff
37766 0xff 0xee
37767 0x0 0x0
37768 0x27 0x10
37769 0x0 0x0
37770 0x27 0x10
37771 0x0 0x0
37772 0x27 0x10
37773 0x0 0x0
37774 0x27 0x10
37775 0x0 0x0
37776 0x0 0x0
37777 0x0 0x0
37778 0x0 0x0
37779 0x0 0x0
37780 0x2 0xc2
37781 0xf9 0x34
37782 0x0 0x8
37783 0x89 0x65
37784 0x0 0x0
37785 0x2 0xa4
37786 0x0 0x0
37787 0x0 0x1e

0x02c2f934 = 46332212

The total discharge can be read from the two registers following that: 0x00088965 = 559461

My conclusion is that the integration is working as intended, as it correctly decodes the values reported by the inverter.

torwag commented 4 days ago

I may add, that I only see this for the main inverter but not for the two identical chained inverters. Would be good to hear if this is always the case as it might help to understand the issue. As all inverters are read in in the same way, I follow @wlcrs statement, that the logic of the integration is correct.

There need to be something else wrong. Interestingly, the reading within the FusionSolar webpage is correct too. Which again, would mean Huawei reads in the register differently for the first inverter compared to the other inverters, or they read in all the inverters with the same logic, but then this problem starts to become puzzling.

torwag commented 40 minutes ago

Hey @wlcrs does closing mean it's fixed, or does closing mean, there is nothing we can do on this side?

Just want to make sure before spending time debugging this.

wlcrs commented 13 minutes ago

I've gone down to actual bits being sent via Modbus to investigate this issue. This integration correctly requests the relevant register and correctly decodes the values being sent back by the inverter. What can/should I fix according to you?