Integration Solar inverter huawei 2000L

Hi i could use some help reading the python code. I would like to know what modbus registers are used when force charge of force discharge is selected. Somehow i cannot seem to find the register numbers in the code for these funciions…

Are you looking in the correct respository or WLCRS’s ? Look in huawei-solar-lib.

You can also look it up on the ‘Solar Inverter Modbus Interface
Definitions’ guide that is included with each release of new firmware for your inverter (or battery).

Perfect, that helps a lot. I guess that i should be able to find the function that calls this. I think multiple registers need to be written as the same time to set it charging/discharging, just need to find what set is used.
By the way, in my Solar Inverter Modbus Interface Definitions list is no mention of register 47100, so i guess i have an old one. Is there a repo somewhere with newer version that you know?

Create and account on Huawei Support : FusionSolar Support, Docs & Downloads - Huawei

It looks like your using the WLCRS integration, so if you need to use this, just setup an automation that calls it.

e.g. If you are pulling in dynamic grid import / export pricing and have a sensor updated every 5 or 30min with the sell price, you could setup an automation that triggers 'when sensor.electricity_fit is >= $ 1 per kWh then call force discharge service.

you then have the option of calling the discharge service where you can set a rate (watts) and time length to discharge for, or the other service that is discharge down to a certain SoC % remaining.

@jbhobson i guess i am still missing something. Can you perhaps point me to an implementation where those functions are being used? I did a grep in the WLCRS repo on “STORAGE_FORCIBLE_CHARGE_DISCHARGE_WRITE” but i only found the register file, so i think i am missing the upper layer logic where the functions are called when someone initiates a charge.
Thanks!

Like:

that is saying…

When :
(entity) 'Electricity - FIT (the sensor showing how much is being paid per kWh to export) is greater than $1.99 p/kWh.

And If :
Solar Production forecast - estimated energy production remaining today is ‘above 10(kwh)’. and

Device ‘Battery’ condition is ‘Current Battery State of Capacity value’ is ‘above 90’%

Then Do:
Call ‘Huawei Solar: Forcible Dischage to a SoC Level’ and discharge to ‘Target SoC (level) = 50%’ and Power (how fast to discharge) = 2500 (W).


Or in the yaml editor version of the automation editor:

description: "LUNA ESS - Force Dischange if FIT >$1.99"
mode: single
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.electricity_fit
    for:
      hours: 0
      minutes: 2
      seconds: 30
    above: 1.99
condition:
  - condition: numeric_state
    entity_id: sensor.energy_production_today_remaining
    above: 10
  - type: is_value
    condition: device
    device_id: <Device ID of the LUNA Battery>
    entity_id: <Entity ID of 'Current Battery State of Capacity Value'>
    domain: sensor
    above: 90
action:
  - service: huawei_solar.forcible_discharge_soc
    data:
      target_soc: 50
      power: "2500"
      device_id: <Device ID of the LUNA Battery>

Hello everyone.
I’ve been using this integration for about 3 years now, and I’ve never had any issues. I have a SUN2000-6KTL-M0 inverter that I access via WLAN-WLAN (internal wifi port 502 slave 0) bridge.
I need to replace the hardware, so I performed a backup and restore on another PC (with the same IP address as the old hardware that I turned off). Everything works fine except for this integration because it fails to establish a connection with the inverter.
I’ve tried removing and reinstalling the integration, and I’ve also tried with a “clean” VM, but it still doesn’t connect.
When I turn on the old hardware, the connection happens immediately without any issues.
I’m desperate, I don’t know what else to do.
In the logs, I find this error:

2024-03-04 09:57:57.663 ERROR (MainThread) [huawei_solar.huawei_solar] Aborting client creation due to error.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/huawei_solar/huawei_solar.py", line 178, in create
    await huawei_solar._initialize()
  File "/usr/local/lib/python3.12/site-packages/huawei_solar/huawei_solar.py", line 107, in _initialize
    self.time_zone = (await self.get(rn.TIME_ZONE)).value
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/huawei_solar/huawei_solar.py", line 241, in get
    return (await self.get_multiple([name], slave))[0]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/huawei_solar/huawei_solar.py", line 276, in get_multiple
    response = await self._read_registers(registers[0].register, total_length, slave)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/huawei_solar/huawei_solar.py", line 398, in _read_registers
    return await _do_read()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/huawei_solar/huawei_solar.py", line 351, in _do_read
    response = await self._client.read_holding_registers(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pymodbus/client/base.py", line 207, in async_execute
    raise ModbusIOException(
pymodbus.exceptions.ModbusIOException: Modbus Error: [Input/Output] ERROR: No response received after 3 retries

The log from the old PC instead is:

2024-03-04 09:34:01.225 DEBUG (MainThread) [pymodbus.logging] Connecting to 192.168.8.1:502.
2024-03-04 09:34:01.225 DEBUG (MainThread) [pymodbus.logging] Connecting comm
2024-03-04 09:34:01.234 DEBUG (MainThread) [pymodbus.logging] Connected to comm
2024-03-04 09:34:01.234 DEBUG (MainThread) [pymodbus.logging] callback_connected called
2024-03-04 09:34:01.235 DEBUG (MainThread) [huawei_solar.modbus] Waiting for 1500 milliseconds after connection before performing operations
2024-03-04 09:34:01.236 INFO (MainThread) [huawei_solar.huawei_solar] Waiting for connection ...
2024-03-04 09:34:02.737 DEBUG (MainThread) [huawei_solar.huawei_solar] Reading register 43006 with length 1 from slave 0
2024-03-04 09:34:02.737 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x3 0xa7 0xfe 0x0 0x1
2024-03-04 09:34:02.738 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1
2024-03-04 09:34:02.744 DEBUG (MainThread) [pymodbus.logging] recv: 0x0 0x1 0x0 0x0 0x0 0x5 0x0 0x3 0x2 0x0 0x78 old_data:  addr=None

I’ve searched the forum and documentation but I was unable to find any info on how to wake the battery. I don’t want to use the capacity mode since it uses up too much battery. So I wrote my own peak prediction and would lower the minimal DOC to handle the peaks. The issue is that the battery completely ignores this command while in sleep, I get a slave failure error.
Anyone who has any idea to wake the battery without charging it?
Since Charging the battery at peak moment doesn’t sound like a good idea…

I’ve been running tests for two days now. I restored again from a new backup of the functioning PC, and I tried with “clean” VMs, but the result remains the same.
I also tried using not only the same IP address but also the same MAC address, but nothing changes. I’m desperate because I need to change hardware. I tried with TCPDUMP, and I see that there is some response from the inverter, but the integration retries as if the response obtained were misinterpreted or denied access.
The inverter only accepts the old PC that I connected years ago. In my opinion, the integration during the connection was doing something that it no longer does, and that has been saved somewhere, I don’t know, theoretically using the machine backup should transfer everything…
I don’t know, but this is a huge problem for me! The firmware version of the inverter is updated, and it is V100R001C00SPC153, doesn’t have the O&M option, so I can’t make it communicate through the dongle; I must necessarily use the internal Wi-Fi.
Is there anyone who can help me???

Another question… where can I see the version of the SDongle? With the Fusion Solar app, I’ve looked everywhere in all the menus and sub-menus, but I can’t find this information anywhere, only the inverter version…

sDongle version is easily available in FusionSolar, got to your site name, expand that and it shows dongle. Click on that and its in the information section on the right panel.

Have you gone ‘back to basics’ and read the Wiki on how to install this and get running with HA + WLCRS ?

Look at ‘Option B’ whereby you should be connecting to the IP address of the sDongle (either WiFi or Ethernet… even though WiFi strangely seems mroe reliable), using the inverters onboard WiFi AP, that is only there for commissioning the inverter, should be seen as a ‘last resort’ method.

On the same screen view I mentioned above, if you click the ‘Configuration’ tab and scroll down there is the ‘Modbus-TCP’ box, that you need to ensure is set to ‘Enabled (Unlimited)’, then you can usually connect on port 6607 (502 is usually the ‘older’ option).

Re your firmware your running some slightly older firmware (the latest tested for M1 inverter is SPC160 with v2xxx SPC110 for the sDongle) however SPC153 and v1 / v2 (SPC108) firmware has been tested and works fine with WLCRS.

I’m sorry, but I don’t speak English, this that I’m writing is translated with chatgpt and I hope it’s understandable. For us who don’t know the English language, everything is always enormously more difficult and complicated.
I have updated and now the inverter has version V100R001C00SPC159 and the dongle version V100R001C00SPC123. I saw that for the SDongleA-01 version V200R022C10SPC108 is also available, but I didn’t have the courage to install it, do you recommend putting this one?
For 3 years I have had Home Assistant correctly connected to the inverter with the onboard WiFi AP connection (port 502 slave ID 0). I want to replace the minipc and when restoring the backup the connection to the inverter doesn’t come up.
I tried to delete and install the integration but it doesn’t connect. I also tried a clean installation of Home Assistant but it doesn’t connect. All this obviously with the old minipc turned off. I also tried to use the same IP address and MAC address as the old minipc but it still doesn’t connect.
I have SUN2000-6KTL-M0 (Three Phase - SUN2000 M0 Hybrid) so from the document you linked I understand that I can only use Option B port 502 slave ID 1, is that correct?
If I understand correctly, Option B means connecting using the dongle’s WiFi and not the onboard WiFi AP that I was using now, is that correct?
At the dongle’s WiFi IP address using nmap I see:

PORT STATE SERVICE
502/tcp closed mbap
PORT STATE SERVICE
6607/tcp closed unknown

If I go to the FusionSolar app in ‘Configuration’, there’s no ‘Modbus-TCP’ option, and I can’t find it anywhere (see image).
The only open port I see with nmap is 502 on the onboard WiFi AP which is the one I used up to now with the old minipc but the new minipc doesn’t connect (when I turn on the old minipc it connects immediately).

When you say ‘replace the hardware’, I assume you had a fault and are saying you had to remove faulty inverter and replace with new unit?

V200R022C10SPC110 is available also, I installed it a week ago and it is running fine.

I run 2 x SUN2000-6KTL-M1 Hybrid with DTSU-666H meter and 38 x 600W optimisers (19 each inverter), so it should be similiar. Checking and the M0 and M1 use the same firmware.
Latest firmware is SUN2000MAV100R001C00SPC161, however FusionSolar may not have it showing. In Australia the latest showing is SPC160, that I have installed last week and it runs fine with WLCRS.

SPC159 that your running is ‘close enough’, worth updating the dongle firmware to v2 though, as it some point you will be forced to if you ever want to connect to EMMA / SmartGuard / new LUNA S1 etc.

Do you have your site talking without issues to FusionSolar ? If so, then you know your RS485 (to DTSU-666H meter and optional other inverters/battery) and sDongle to internet is working.

So now you need to check you can connect to the sDongle using modbus (could be either port 6607 or 502, but looking at mine with v2 firmware it is showing tcp port 502).

In FusionSolar ( portal not the phone app, is easier. https://intl.fusionsolar.huawei.com )

Open… Monitoring, then the site name, then the dongle. Then on the right side, click on ‘Configuration’ and scroll down and you should see ‘ModBus-TCP’. Make sure this is set to 'Enable (unrestricted).

Then add it into HA / WLCRS, using the (STATIC IP !) and tcp port 502 (Default. 6607 is the other possibility). If you only have 1 inverter, then the default setting would be ‘1’ for the inverter ID, otherwise with multiple inverters you have to check (using the phone app in commissioning mode) the ID number the installer configured. i.e. I have 2 inverters the installer configured the primary inverter as ID 2 and the secondary as ID 1. So know I have to add into WLCRS as ID = 2,1.

1 Like

First of all, thank you for the help you’re providing, you’re very kind!

When I say replacing the hardware, I mean the PC on which Home Assistant has been running for 3 years. It’s a very old NUC with some issues, and now I want to use a new NUC with Proxmox.

I’ve backed up the old NUC where huawei-solar has been working perfectly for 3 years. When I restore it onto a Proxmox VM, everything works except for huawei-solar, which doesn’t connect. It’s very strange because the network and the inverter haven’t changed at all. I’ve also tried with a clean VM, but it still doesn’t connect. I even tried using the same IP and MAC address as the old NUC, but it doesn’t connect. When I turn on the old NUC, the connection is immediate (with the Wi-Fi AP Dongle that has port 502 open).

The page you’re showing me in my dongle is unfortunately different, and there’s no ModBus-TCP, but I have SDongleA-01 (without FE) and not SDongleA-05, which seems to be what everyone else has. I’ve tried searching the web, but it seems like I’m the only one in the world with SDongleA-01.

I’ve tried to install V200R022C10SPC108 on the Dongle, but it fails, giving me an error of wrong version even though it appears among the available versions for my Dongle.

It’s as if three years ago, the first time the old NUC connected, it established a connection with the inverter that is now maintained, but the new versions of the integration no longer allow to establish it. The connection made previously continues to work with the new versions, but it’s no longer possible to establish a new connection. That’s why I also tried to replicate the IP address and MAC address, but there’s something else that doesn’t transfer even when using the full backup.

I’m desperate. It’s been a week that I’ve been working on this, and I don’t know what else to do. I don’t want to continue with the old NUC with issues, but the alternative is giving up on having control of the inverter on Home Assistant (which is the main reason I installed HA)… ;(

@wlcrs I’m sorry for tagging you, but only you can help me


Hello. I have a sun2000-33ktl grid inverter. Monitoring is carried out through the application in the SUN2000 phone. Connecting the phone to the inverter via a bluetooth module, which is inserted into the USB socket of the inverter. the RS485 pins are labeled RS485A IN, RS485A OUT, RS485B IN, RS485B OUT. If I understand correctly, I need to purchase the Elfin-EW1X adapter. But to which contacts should it be connected? Will this integration work with my inverter? Thank you.

Your inverter manual refers to having an optional Ethernet interface.
https://ske-solar.com/wp-content/uploads/2020/08/Handbuch-Huawei-SUN2000-33KTL-A.pdf#[{"num"%3A101%2C"gen"%3A0}%2C{"name"%3A"XYZ"}%2C54%2C376%2C0]

If you also lookup the lastest firmware package for your inverter it should also contain a copy of ‘Solar Inverter Modbus Interface Definitions’, the most recent I have for my 6KTL-M1 is ‘Issue 05. Date 2023-02-16’

On page 4 is shows:

So, assuming you can get an ethernet connection for the inverter to your network/PC (or use something like an Elfin appliance, BUT that will usually stop your inverter also being able to connect to FusionSolar portal !), then WLCRS should work for you.

This is on the basis that the library that WCLRS uses to communicate with the inverters/optimisers/battery/meter etc calls the same modbus registers that all those inverters in that document use.

Thank you very much. There was little information in my paper instructions. Ordered the Elfin-EW11. I will try to connect.

Yes, I have the same setup (master+ inverter), also each of them with a battery (2 inverters + 2 batteries).
You just have to find the modbus ID of the slave. In my case, it was 16. When setting up the integration, use the same IP address as the master, but the modbus to 16 (or whatever is in your case)

Hello,

I applied your solution correctly.

The problem is that when there is no longer any solar production, the calculated energy decreases since there is “- Battery day discharge”.

I have negative value in the energy dashboard.
But the total yield daly also reduced in the fusion solar application.

Do you also have this problem?

image

Thanks for your reply.

Hello!
I’ve a SNU2000 4.6 with 5 kw Luna battery and a DDSU666-H installed correctly.
The thing is that I can’t understand which is the sensor that reads the house imported energy from the grid (the one I pay for) in roder to correctly set up the energy dash and calculate the money spent.
Any help from your experience?

Do you mean the ‘power meter’ in HA, and then the ‘Active Power’ (sensor.power_meter_active_power) that shows the Watts being used, with either a negative number (importing from grid) or a positive number (exporting to grid) ?

If this is what you mean, you need to define a ‘derived sensor’ for “House - Consumption Power” to use that raw sensor and calculate/track power being imported vs exported.

To track the amound of kWh being exported vs imported you also then need to use that sensor and then use a utility_meter (or better still use GitHub - zeronounours/HA-custom-component-energy-meter: Provides extended features on top of utility-meter to track costs for each tariff as well as total costs ) with it and then setup daily / weekly / monthly / yearly etc for that sensor. That will then give you sensors for each specific period, tracking the kWh imported and exported.

Suggest you have a look at:

and the huawei_derived_sensors.yaml and example files that also give price sensors for TOU tariff huawei_solar_electricity_costs_AU_Red_Energy_TOU.yaml or this one that is for a flat rate tariff huawei_solar_electricity_costs_AU_Synerg_Energy_Flate_Rate.yaml

1 Like