Integration Solar inverter huawei 2000L

I have following error:
ERROR (MainThread) [homeassistant.components.sensor] Setup of platform huawei_solar is taking longer than 60 seconds. Startup will proceed without waiting any longer.
Any ideas how to solve it? Conncetion to huawei inverter via python works fine.

Log Details (ERROR)
Logger: homeassistant.components.sensor
Source: custom_components/huawei_solar/sensor.py:270
Integration: Sensor (documentation, issues)
First occurred: 3:45:25 PM (1 occurrences)
Last logged: 3:45:25 PM

huawei_solar: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 169, in read_register
    response = self.client.read_holding_registers(register, length)
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers
    return self.execute(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/client/sync.py", line 109, in execute
    return self.transaction.execute(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/transaction.py", line 173, in execute
    response, last_exception = self._transact(
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/transaction.py", line 289, in _transact
    result = self._recv(response_length, full)
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/transaction.py", line 320, in _recv
    read_min = self.client.framer.recvPacket(min_size)
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/framer/__init__.py", line 49, in recvPacket
    return self.client.recv(size)
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/client/sync.py", line 89, in recv
    return self._recv(size)
  File "/srv/homeassistant/lib/python3.9/site-packages/pymodbus/client/sync.py", line 298, in _recv
    return self._handle_abrupt_socket_close(
  File "/srv/homeassistant/lib/python3.9/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.8.1:502): Connection unexpectedly closed 0.080834 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 "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 465, in async_device_update
    await task
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/huawei_solar/sensor.py", line 270, in update
    self._phase_B_current = self._inverter.get("phase_B_current").value
  File "/srv/homeassistant/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 40, in get
    response = self.read_register(reg.register, reg.length)
  File "/srv/homeassistant/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 172, in read_register
    raise ConnectionException(ex)
huawei_solar.huawei_solar.ConnectionException: Modbus Error: [Connection] ModbusTcpClient(192.168.8.1:502): Connection unexpectedly closed 0.080834 seconds into read of 8 bytes without response from unit before it closed connection

Hi again,

Since I couldnā€™t figure out what is wrong with ā€œhuawei_solarā€ - GitHub - Emilv2/huawei_solar: Home Assistant custom component for Huawei inverters

I just used embeded in HA modbus - Modbus - Home Assistant

In my opinion its better solution (no custom repos etc) since to setup integration with inverter we need: HA and connection to inverter (working modbus tcp on 502) - nothing more.

In link below you can find pdf - ā€œMODBUS Interface Definitionsā€ - information about correct registry numbers:

About correct types (string int etc) you can read here: Modbus - Home Assistant

Quantity in PDF = Modbus - Home Assistant

Here is my test working config:

modbus:
type: tcp
host: 192.168.8.1
port: 502

sensor:

  • platform: modbus
    scan_interval: 60 time in seconds for getting values
    registers:
    • name: PV1 voltage
      register: 32016
      data_type: int
      scale: 0.1
      precision: 1
    • name: PV1 current
      unit_of_measurement: A
      register: 32017
      data_type: int
      scale: 0.01
      precision: 2
    • name: Active Power Peak
      unit_of_measurement: kW
      count: 2
      register: 32080
      data_type: int
    • name: Input power
      unit_of_measurement: kW
      count: 2
      register: 32064
      data_type: int
    • name: Max active power
      unit_of_measurement: kW
      count: 2
      register: 30075
      data_type: uint
    • name: Daily production
      unit_of_measurement: kWh
      count: 2
      register: 32114
      data_type: uint
      scale: 0.01
      precision: 2
    • name: Model name
      register: 30000
      count: 15
      data_type: string

BR,
Bekon

2 Likes

Good news!
Unfortunately the storage battery related quantities are not listed.
Somebody know how they can be found?

PDF from my post is from: 2019-01-02 - maybe you need newer version.

I think I can take a look at it by the weekend

1 Like

Yes this is possible and will get you the most needed values. Only getting startup times and status values will be a bit more complicated. My goal is to get this custom component in the official release so no messing around with custom repos will be needed.

2 Likes

Here are interface definitions with battery information: Interface definitions (V.3.0).pdf

Great! Thank you so much.

Unfortunately, I have exactly the same problem. When upgrading from core-2021.2.3 to core-2021.3.4, the integration stops working. The logs are identical.

Thanks, this works great!

Minor quibble, the pdf does say the various wattage fields are in kW, but they seem to be measuring watts, at least on my 2000L.

The pdf is correct, but a bit confusing. There is also a gain factor you need to divide by to get the correct units.

Hey just checking if there has been any progress?

Also setup instructions mention HAC but Iā€™m unable to find the integration in the search, do I need to do something manually?

Google ā€œHow to install HACS on Home Assistantā€

I already had HACS installed but I couldnā€™t find the Huawei Solar integration however all good I figured out that it wasnā€™t in the list of integrations available and I needed to manually add the github link as a repository.

Any news on the integration being fixed as its been out for over 2 weeks now and iā€™m contemplating making the switch the modbus method listed above?

1 Like

Hi,

Iā€™ve been following this topic for a while now and used Emilā€™s integration for quite some time.
Just a few days ago, I implemented the modbus protocol into my HA and thought Iā€™d share some of my code:

configuration.yaml

modbus:
  name: solar
  type: tcp
  host: 192.168.8.215
  port: 502

sensor: !include_dir_merge_list sensors/

sensors/huawei_solar.yaml

---
# Slow refresh solar registries
- platform: modbus
  scan_interval: 14400 # 4 uur
  registers:
    - name: Solar Model name
      hub: solar
      register: 30000
      count: 15
      data_type: string
    - name: Solar Installed optimizers
      hub: solar
      register: 37200
      data_type: uint
    - name: Solar Max active power
      hub: solar
      unit_of_measurement: W
      count: 2
      register: 30075
      data_type: uint
    - name: Solar total production
      hub: solar
      unit_of_measurement: kWh
      count: 2
      register: 32114
      data_type: uint
      scale: 0.01
      precision: 2

# Medium refresh solar registries
- platform: modbus
  scan_interval: 300 # 5 minuten
  registers:
    - name: Solar phase A Voltage
      hub: solar
      unit_of_measurement: V
      register: 32069
      data_type: uint
      scale: 0.1
      precision: 1
    - name: Solar Internal temperature
      hub: solar
      unit_of_measurement: Ā°C
      register: 32087
      scale: 0.1
      precision: 1
      data_type: int
    - name: Solar Status Raw
      hub: solar
      register: 32089
      data_type: uint
    - name: Solar Daily production
      hub: solar
      unit_of_measurement: kWh
      count: 2
      register: 32114
      data_type: uint
      scale: 0.01
      precision: 2
    - name: Solar Optimizers online
      hub: solar
      register: 37201
      data_type: uint
    - name: Solar Active Power
      hub: solar
      unit_of_measurement: W
      count: 2
      register: 32080
      data_type: int
    - name: Solar Input power
      hub: solar
      unit_of_measurement: W
      count: 2
      register: 32064
      data_type: int
#    - name: test Solar Optimizers data
#      hub: solar
#      register: 37202
#      count: 29
#      data_type: float

# Fast refresh solar registries
- platform: modbus
  scan_interval: 30
  registers:
    - name: Solar PV1 voltage
      hub: solar
      unit_of_measurement: V
      register: 32016
      data_type: int
      scale: 0.1
      precision: 1
    - name: Solar PV1 current
      hub: solar
      unit_of_measurement: A
      register: 32017
      data_type: int
      scale: 0.01
      precision: 2
    - name: Solar PV2 voltage
      hub: solar
      unit_of_measurement: V
      register: 32018
      data_type: int
      scale: 0.1
      precision: 1
    - name: Solar PV2 current
      hub: solar
      unit_of_measurement: A
      register: 32019
      data_type: int
      scale: 0.01
      precision: 2
    - name: Solar Active Power
      hub: solar
      unit_of_measurement: W
      count: 2
      register: 32080
      data_type: int

- platform: template
  sensors:
    solar_status:
      friendly_name: "Solar Status"
      value_template: >-
        {% if   is_state('sensor.solar_status_raw',     '0') %}  Standby: initializing
        {% elif is_state('sensor.solar_status_raw',     '1') %}  Standby: detecting insulation resistance
        {% elif is_state('sensor.solar_status_raw',     '3') %}  Standby: grid detecting
        {% elif is_state('sensor.solar_status_raw',   '256') %}  Starting
        {% elif is_state('sensor.solar_status_raw',   '512') %}  On-grid
        {% elif is_state('sensor.solar_status_raw',   '513') %}  Grid Connection: power limited
        {% elif is_state('sensor.solar_status_raw',   '514') %}  Grid Connection: self-derating
        {% elif is_state('sensor.solar_status_raw',   '768') %}  Shutdown: fault
        {% elif is_state('sensor.solar_status_raw',   '769') %}  Shutdown: command
        {% elif is_state('sensor.solar_status_raw',   '770') %}  Shutdown: OVGR
        {% elif is_state('sensor.solar_status_raw',   '771') %}  Shutdown: communication disconnected
        {% elif is_state('sensor.solar_status_raw',   '772') %}  Shutdown: power limited
        {% elif is_state('sensor.solar_status_raw',   '773') %}  Shutdown: manual startup required
        {% elif is_state('sensor.solar_status_raw',   '774') %}  Shutdown: DC switches disconnected
        {% elif is_state('sensor.solar_status_raw',   '775') %}  Shutdown: rapid cutoff
        {% elif is_state('sensor.solar_status_raw',   '776') %}  Shutdown: input underpowered
        {% elif is_state('sensor.solar_status_raw',  '1025') %}  Grid scheduling: cosphi-P curve
        {% elif is_state('sensor.solar_status_raw',  '1026') %}  Grid scheduling: Q-U curve
        {% elif is_state('sensor.solar_status_raw',  '1027') %}  Grid scheduling: dry contact
        {% elif is_state('sensor.solar_status_raw',  '1028') %}  Grid scheduling: Q-P curve
        {% elif is_state('sensor.solar_status_raw',  '1280') %}  Spot-check ready
        {% elif is_state('sensor.solar_status_raw',  '1281') %}  Spot-checking
        {% elif is_state('sensor.solar_status_raw',  '1536') %}  Inspecting
        {% elif is_state('sensor.solar_status_raw',  '1792') %}  AFCI self check
        {% elif is_state('sensor.solar_status_raw',  '2048') %}  I-V scanning
        {% elif is_state('sensor.solar_status_raw',  '2304') %}  DC input detection
        {% elif is_state('sensor.solar_status_raw',  '2560') %}  Running: off-grid charging
        {% elif is_state('sensor.solar_status_raw', '40960') %}  Standby: no irradiation
        {% else %}
          Failed to read sensor
        {% endif %}

This works like a charm for me, and I love that there now are separate entities, which makes it easier to design a dashboard in ā€œvanillaā€ HA. Itā€™s a WIP.

4 Likes

Thanks, Iā€™m using similar method.

But I have problems every morning with connection to my inverter. It seems like when inverter goes to standby mode in the night, my HA modbus couldnā€™t connect back to it in the morning.
HA do not read values till I disconnect and connect back my wifi adapter.

Does someone had similar problems?

I have optimizers installed and wonder if there is away to read out data from those? I use Emilv2 excellent component.

Hi,

I tried Emilv2 component, I see inverted added, entities added in the log entries, but no entity is created.
If I use the modbus component, Iā€™m able to read out some values.

I have a SUN2000-4.6KTL-L1 inverter.
Can somebody provide troubleshooting steps i can use to get the custom component working?

Not sure how to explain this but Emilv2 component has not been working for me for some weeks so today I finally decided to make the switch and try the modbus

I added the below modbus lines plus some of the platform sensors listed in previous threads and all of a sudden Emilv2 component started to work again?

modbus:
name: solar
type: tcp
host: 192.168.x.x
port: 502

Hi Gerry,

if you use a single phase connection, you have to use register 32066 instead of 32069 to get the correct voltage.

1 Like