Integration Solar inverter huawei 2000L

I am currently trying to set this up for my inverter (Huawei SUN2000-3KTL-L1, connected via WiFi dongle), however I seem to be getting the following problem. I can connect to that host and port via telnet, so that [wrong ip] does not seem to be the issue. Is this inverter unsupported or am I doing something wrong?

For completeness sake, the config (I do not have batteries, but I do have optimizers):

sensor:
  - platform: huawei_solar
    host: '192.168.178.173'
    optimizers: true
#    battery: false

Logs:

2021-05-20 13:19:40 ERROR (SyncWorker_2) [huawei_solar.huawei_solar] failed to connect to device, is the host correct?
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/huawei_solar/huawei_solar.py", line 172, in read_register
    response = self.client.read_holding_registers(register, length)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers
    return self.execute(request)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 109, in execute
    return self.transaction.execute(request)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/transaction.py", line 173, in execute
    response, last_exception = self._transact(
  File "/usr/local/lib/python3.8/site-packages/pymodbus/transaction.py", line 290, in _transact
    result = self._recv(response_length, full)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/transaction.py", line 321, in _recv
    read_min = self.client.framer.recvPacket(min_size)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/framer/__init__.py", line 49, in recvPacket
    return self.client.recv(size)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 89, in recv
    return self._recv(size)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 298, in _recv
    return self._handle_abrupt_socket_close(
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 343, in _handle_abrupt_socket_close
    raise ConnectionException(msg)
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] ModbusTcpClient(192.168.178.173:502): Connection unexpectedly closed 0.000129 seconds into read of 8 bytes without response from unit before it closed connection
2021-05-20 13:19:40 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.sun2000_3ktl_l1 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/huawei_solar/huawei_solar.py", line 172, in read_register
    response = self.client.read_holding_registers(register, length)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers
    return self.execute(request)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 109, in execute
    return self.transaction.execute(request)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/transaction.py", line 173, in execute
    response, last_exception = self._transact(
  File "/usr/local/lib/python3.8/site-packages/pymodbus/transaction.py", line 290, in _transact
    result = self._recv(response_length, full)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/transaction.py", line 321, in _recv
    read_min = self.client.framer.recvPacket(min_size)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/framer/__init__.py", line 49, in recvPacket
    return self.client.recv(size)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 89, in recv
    return self._recv(size)
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 298, in _recv
    return self._handle_abrupt_socket_close(
  File "/usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py", line 343, in _handle_abrupt_socket_close
    raise ConnectionException(msg)
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] ModbusTcpClient(192.168.178.173:502): Connection unexpectedly closed 0.000129 seconds into read of 8 bytes without response from unit before it closed connection

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 316, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 524, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/huawei_solar/sensor.py", line 257, in update
    self._state = self._inverter.get("active_power").value
  File "/usr/local/lib/python3.8/site-packages/huawei_solar/huawei_solar.py", line 40, in get
    response = self.read_register(reg.register, reg.length)
  File "/usr/local/lib/python3.8/site-packages/huawei_solar/huawei_solar.py", line 175, in read_register
    raise ConnectionException(ex)
huawei_solar.huawei_solar.ConnectionException: Modbus Error: [Connection] ModbusTcpClient(192.168.178.173:502): Connection unexpectedly closed 0.000129 seconds into read of 8 bytes without response from unit before it closed connection

I have already solved the connection problems, in my case the inverter was defective, after several tests with the huawei support they indicated that some internal memories of the inverter did not work well, they have changed the inverter and everything has been solved. Thankyou for your help.

Ciao @Emilv2 any progress on battery sensors? There must be an issue in the IF check or similar, as i tried to update sensors.py to include STORAGE_STATUS independently of the Battery_Installed IF and I was able to get value in HA.

Thanks!

Ciao Valentino, posso chiederti come hai fatto a fare questo tipo di visualizzazione?Grazie

Ciao posso chiederti come hai fatto a fare questa grafica?

The shown views are screenshots of the Huawei app, not from home assistant.
If you search something nice, visit Custom Solar Power Card the Tesla Style (almost)

Hi guys,
The Huawei FusionSolar website has just be updated and so is the API. The old API
http://sg5.fusionsolar.huawei.com/kiosk/getRealTimeKpi
no longer works.

Do you folks have the new endpoint for the API?

Thanks.

Dear Emilv2 ho seguito la tua procedura copiando i file e indicando anche ip dell’inverter ma non non vendo dispositivi o entità in home assistant dove sbaglio?mi puoi aiutare?grazie mille

Does 2021.6 update fixes the issue?

1 Like

I have it running for 12 hours with no issues in the modbus extension yet, my average rate of failure was every 12-18 hours in 2021.5
Make a backup before upgrade if you try.

How did you connect it with modbus? any special hardware required??
I have raspberry pi running home assistant. Inverter is within the range of wifi router. Ip for wifi router is 192.168.18.1. How should I connect it?

@Emilv2 I’ve got battery status finally working in HA.
I had to add the sensor 37004 as U16 to huawei_solar.py first, later I included it in sensor.py and it’s successfully working.

Hi there Hybrix. Can you guide me to your solution. I can’t get the battery status to work.

no. not working for me. 2021.6 on version 2021.5 all is ok

Hi all,

This is my first post in this forum, and I ask you to excuse my bad English. It is to thank everyone who has contributed ideas and information and tell them what my solution was.

I made a small pcb with an esp8266 and an rs232 interface, this for various integrations. Then using a rs232 to rs485 converter I connected it to the inverter’s modbus.

I have a sun2000-5ktl-l1 with a power meter to limit the injection.

The software I made for the esp8266, periodically read the reggisters that interested me and send them via MQTT to home assistant.
I have implemented the solution for 6 months and it has been very stable, always working correctly, despite inverter or home assistant updates.

Greetings to all from Argentina.

First of all, I had to modify huawei_solar.py to add the following line:

"storage_charge_status": RegisterDefinitions("u16", "W", 1, 37004, 1)

Since I don’t know how to manually reinstall a python package, I search for huawey_solar.py under linux and I updated all including above line.

Later I took sensor.py (under custom components) and I added the same attribute and it finally worked successfully.
Cheers


Installed but how do I operate it?

Hey all, so my inverter gets installed on Thursday, and I was just wondering, with this thread offering a few methods, what is the best way to integrate this with HA now?

Does Emil’s plugin still work?
Is it 100% required to use the wifi bridge, using an RPi or similar?

Thanks

Once you add the sensor to sensor.yaml a new sensor called sun2000 will show Up.

Emilv2 component works fine. I haven’t tried other way as this one works fine.

1 Like