Integration Solar inverter huawei 2000L

after 2023.06.2 upgrade, getting the error below:

Logger: homeassistant.components.sensor
Source: custom_components/huawei_solar/sensor.py:169
Integration: Sensor (documentation, issues)
First occurred: 7:19:50 AM (1 occurrences)
Last logged: 7:19:50 AM

Error while setting up huawei_solar platform for sensor

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 320, in _async_setup_platform await asyncio.shield(task) File “/config/custom_components/huawei_solar/sensor.py”, line 169, in async_setup_platform inverter = AsyncHuaweiSolar( ^^^^^^^^^^^^^^^^^ TypeError: AsyncHuaweiSolar.init() got an unexpected keyword argument ‘host’

Can you please test again with the latest beta version (v1.2.6 beta 6) ?

Beta version fixed my problem. thank you.

Hi Wlcrs,

I was actually using @Emilv2 's integration which worked fine until now. So, I was not aware of your development :slight_smile: . Anyway, I gave it a try, but I cannot connect to my inverter.

I get this:

Source: /usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py:175
First occurred: 9:49:00 PM (1 occurrences)
Last logged: 9:49:00 PM

Aborting client creation due to error.
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 339, in _do_read
    response = await self._client.read_holding_registers(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pymodbus/client/base.py", line 231, in async_execute
    resp = await asyncio.wait_for(req, timeout=self.params.timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 169, in create
    await huawei_solar._initialize()
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 104, in _initialize
    self.time_zone = (await self.get(rn.TIME_ZONE)).value
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 229, in get
    return (await self.get_multiple([name], slave))[0]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 264, in get_multiple
    response = await self._read_registers(registers[0].register, total_length, slave)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 386, in _read_registers
    return await _do_read()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 171, in retry
    await _call_handlers(on_backoff, **details, wait=seconds,
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 37, in _call_handlers
    await handler(details)
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 16, in f
    return coro_or_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 298, in on_backoff_with_reconnect
    if details.tries % 2 == 0:
       ^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'tries'

I saw that Emil did the same commit on his repository, but it is not working also. In case someone is using that one too.

Logger: homeassistant.components.sensor
Source: custom_components/huawei_solar/sensor.py:169
Integration: Sensor (documentation, issues)
First occurred: 10:06:25 PM (1 occurrences)
Last logged: 10:06:25 PM

Error while setting up huawei_solar platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/huawei_solar/sensor.py", line 169, in async_setup_platform
    inverter = AsyncHuaweiSolar(
               ^^^^^^^^^^^^^^^^^
TypeError: AsyncHuaweiSolar.__init__() got an unexpected keyword argument 'host'

Hi, i had the same problem and wrote an issue in huawei-solar

there is a new version 2.2.7b7 which solves the problem.
The component already updated to this version.

Thank you for that first stack trace. I’ve fixed the issue in 1.2.6b7.

Hi Wlcrs, thanks for your help, but I still can’t connect.

I am trying to connect to the SDongle which is in the same network as Hass, and I have 502 open on it. I added slave ID 1 for SDongle.

Logger: huawei_solar.huawei_solar
Source: /usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py:175
First occurred: 11:01:38 AM (1 occurrences)
Last logged: 11:01:38 AM

Aborting client creation due to error.
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 337, in _do_read
    raise ConnectionInterruptedException(message)
huawei_solar.exceptions.ConnectionInterruptedException: Modbus client is not connected to the inverter.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 169, in create
    await huawei_solar._initialize()
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 104, in _initialize
    self.time_zone = (await self.get(rn.TIME_ZONE)).value
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 229, in get
    return (await self.get_multiple([name], slave))[0]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 264, in get_multiple
    response = await self._read_registers(registers[0].register, total_length, slave)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 386, in _read_registers
    return await _do_read()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 159, in retry
    await _call_handlers(on_giveup, **details, exception=e)
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 37, in _call_handlers
    await handler(details)
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 16, in f
    return coro_or_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 315, in backoff_giveup
    raise ReadException(f"Failed to read register {register} after {details['tries']} tries")
huawei_solar.exceptions.ReadException: Failed to read register 43006 after 6 tries

The stack trace shows that the inverter does not react to the query in time, even after retrying 6 times. It is retrying as intended.

Hi,
i’ve installed an huawei inverter (SUN2000-6KTL-L1) but i don’t manage to integrate it with home assistant.
On my router i’ve three devices connected:



Which of the three do I have to connect to read the data in Modbus? And above all, which port should I use? The 502 or the 6607? I have already enabled Modbus in the dongle settings.

I’ve tried to connect with 192.168.1.101 but i’ve this error on my log:

Logger: huawei_solar.huawei_solar
Source: /usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py:143
First occurred: 19:39:00 (1 occurrences)
Last logged: 19:39:00

Aborting client creation due to error.
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 294, in _do_read
    raise ConnectionInterruptedException(message)
huawei_solar.exceptions.ConnectionInterruptedException: Modbus client is not connected to the inverter.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 137, in create
    await huawei_solar._initialize()
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 90, in _initialize
    self.time_zone = (await self.get(rn.TIME_ZONE)).value
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 215, in get
    return (await self.get_multiple([name], slave))[0]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 250, in get_multiple
    response = await self._read_registers(registers[0].register, total_length, slave)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 328, in _read_registers
    result = await _do_read()
             ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 159, in retry
    await _call_handlers(on_giveup, **details, exception=e)
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 37, in _call_handlers
    await handler(details)
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 16, in f
    return coro_or_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 276, in backoff_giveup
    raise ReadException(f"Failed to read register {register} after {details['tries']} tries")
huawei_solar.exceptions.ReadException: Failed to read register 43006 after 6 tries

Thanks in advance for any help.
Regards,

Alessandro

My assumption is the last one is the LAN cable to the Dongle. I would go forward with this one.

If that does not work, use the Dongle/wifi one

Hey Folks,

Does anyone have the problem with using utility meters for Inverter Selfuse ( yield - exported + consumption )?

For me the utility meters / are not showing the right values for calculated totals/daily’s.
This is the case for Selfuse energy (what I used off my PV), as well as load energy (what my house used)

Selfuse_energy_total (just by looking at values) daily should be around 10,1 kWh

Selfuse_energy is based off the daily sensors from the integration

Selfuse_energy_daily is based off the totals sensors and calculated as utility_meter

Here are the sensor templates


  - name: "selfuse_energy_total"
    unique_id: selfuse_energy_total
    unit_of_measurement: 'kWh'
    icon: mdi:flash
    device_class: energy
    state_class: total
    state: >
      {{ states('sensor.inverter_total_yield')|float(0) - 
      states('sensor.power_meter_exported')|float(0) 
      }}
    availability: >
      {{ states('sensor.inverter_total_yield')| is_number and 
         states('sensor.power_meter_exported')| is_number
      }}    
   

Total_energy (used in Selfuse_energy)


  - name: "total_energy"
    unique_id: total_energy_fs
    state: "{{ (states('sensor.inverter_daily_yield')|float(0))  | round(2) }}"
    unit_of_measurement: "kWh"
    device_class: energy

Selfuse_energy


    # Eigenverbrauch PV Tag
  - name: "selfuse_energy"
    unique_id: selfuse_energy
    unit_of_measurement: 'kWh'
    icon: mdi:flash
    state: "{{ ( states('sensor.total_energy')|float(0) - states('sensor.exported_energy_daily')|float(0) )|float(0) }}"
       

Utility-meters


# Eigenverbrauch
  selfuse_energy_daily:
    source: sensor.selfuse_energy_total
    cycle: daily
  selfuse_energy_monthly:
    source: sensor.selfuse_energy_total
    cycle: monthly
  selfuse_energy_yearly:
    source: sensor.selfuse_energy_total
    cycle: yearly

So obviously the utility meter for daily has the wrong value. Fusion Solar confirms my findings. It always has the identical value as selfuse_energy

If I understood right, the issue is that the utility meter state_class isn’t properly configured.
I had to create this (some of these energy sensors are created from utility meters):

Just for example about what I’m speaking about, see the third method in this guide:

In this way I see 1:1 the values wrote in Fusion Solar app

Yes.
I have no problem with Exported and Yield and Consumption.

There is only a problem with Selfuse (which is based off the 3 above values), and Load (what my house consumes)

After trying lot of option only one that work for me is:
download version 1.2.6b2 not b5 or b7 they dont connect
then use sun2000 on your mobile and connect to your inverter, set fix IP for wifi connection(ex. 192.168.1.114 or something)
try to ping it from your PC , if ping is ok then start to set integration.

first set this ip(192.168.1.114) port is 6607 and slave id is 1, mark eleveate permission and then it will ask you for user and password(same as you type in SUN2000).

For me is worked with salve ID 1, but also somtime it work with 0.

It is very important that you try to ping iverters IP every now and then becouse it go in some version of sleep and you cant set integration if there is more then 5 minuts betwin ping and setting integration( for me i had to connect again with SUN 2000 and reconfigure wifi connetion).

Maybe this isnt right path to do that but it worked for me every time.

i tried 1.2.6.b5 nad b7 but no of those versions cant to conect to mine 4.6 inverter, so i returned to b2
version.

and its is very imoprtant that if you cant to connect in 2 or 3 attempt to restart HA becouse it messup all
connection then.

I see this mentioned in several place: Set a fix/static IP for the inverter before integrating into HA. And that totally makes sense. Currently I can see that the inverter AP has gotten 192.168.1.61 address and is connected to my LAN. But I’d like to change that to give it an address in the range I reserve for devices with fix IP.

But where do you do that? What do you connect to to reach those parameters? I’ve searched the forum, the internet and cannot find that piece of information.

Can anyone please help me?

SUN2000-8KTL-M1 Version: V100R001C00SPC153
SDongleA-05 Version: V100R001C00SPC125

You have to do that in your router, look for DHCP settings or similar.

Sure, I understand the router side… but I first need to go and set the IP address in the inverter before telling the router to “fix” this address. So where to set the IP address in the inverter is what I’m trying to find.

OK, that’s one kind of a router. Most of the routers allow you to preset the IP knowing the MAC address of the dongle.

I strongly advise not going this way.

To set the IP manually within the inverter, you have to use the FusionSolar app on your phone. You have to go to: Settings → Communication configuration → Router connection settings → FE Connection
There you have to flip the DHCP switch off and populate the fields with your desired IP settings.

Greetings,
so i have 3 sensors.
1.Electricity usage from grid
2.Electricity usage of the home
3.Solar production

How can i make this graph with the gradient inside like this one?

Did you manage to figure this out? I am still struggling to calculate the house usage :frowning: