Integration Solar inverter huawei 2000L

That is weird since it’s exactly what my integration does. What happens if you directly use the HuaweiSolar package in python? Install HuaweiSolar through pypi and run this:

import HuaweiSolar
inverter = HuaweiSolar('192.168.5.34')
inverter.get("model_name")

Are you running this on the same machine as HA runs?

Yes, I’m running it on the same machine as HA.
I can’t find HuaweiSolar package. Is it this: https://pypi.org/project/huawei-solar/

>>> import huawei_solar
>>> inverter = HuaweiSolar('192.168.8.1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'HuaweiSolar' is not defined
>>> inverter = huawei_solar('192.168.8.1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable

Oops, this should work:

import huawei_solar
inverter = huawei_solar.HuaweiSolar('192.168.5.34')
inverter.get("model_name")
>>> inverter = huawei_solar.HuaweiSolar('192.168.8.1')
>>> inverter.get("model_name")
Result(value='SUN2000-8KTL-M0', unit=None)
>>> exit

It took about 5 second to get answer from “inverter.get(“model_name”)”. Still it doasn’t work with HA.
In configuration.yaml I have:

sensor: 
  - platform: huawei_solar   
    host: 192.168.8.1
2020-04-23 11:59:01 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform huawei_solar is taking over 10 seconds.
2020-04-23 11:59:06 ERROR (SyncWorker_1) [huawei_solar.huawei_solar] could not read register value, is an other device already connected?
2020-04-23 11:59:06 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up huawei_solar platform for sensor
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\homeassistant\helpers\entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "C:\Python38\lib\asyncio\tasks.py", line 483, in wait_for
    return fut.result()
  File "C:\Python38\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\ligez\AppData\Roaming\.homeassistant\custom_components\huawei_solar\sensor.py", line 61, in setup_platform
    entities.append(HuaweiSolarSensor(inverter))
  File "C:\Users\ligez\AppData\Roaming\.homeassistant\custom_components\huawei_solar\sensor.py", line 80, in __init__
    self._nb_optimizers = self._inverter.get("nb_optimizers").value
  File "C:\Users\ligez\AppData\Roaming\.homeassistant\deps\Python38\site-packages\huawei_solar\huawei_solar.py", line 37, in get
    response = read_register(self.client, reg.register, reg.length)
  File "C:\Users\ligez\AppData\Roaming\.homeassistant\deps\Python38\site-packages\huawei_solar\huawei_solar.py", line 151, in read_register
    raise ReadException(message)
huawei_solar.huawei_solar.ReadException: could not read register value, is an other device already connected?

Hmm, strange. Can you ping the device from HA? (use the ping integration)

Yes, I can ping (binary_sensor online). I started HA, still the same error in HA log. Then in second windows I tested it with

>>> inverter = huawei_solar.HuaweiSolar('192.168.8.1')
>>> inverter.get("model_name")
Result(value='SUN2000-8KTL-M0', unit=None)

HA is clean with minimal configuration, only Ping and Huawei_solar integration

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123
# Text to speech
tts:
  - platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: 
  - platform: huawei_solar   
    host: 192.168.8.1
binary_sensor:
  - platform: ping
    host: 192.168.8.1
    count: 2
    scan_interval: 60

What happens if you run inverter.get("nb_optimizers") ?

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import huawei_solar
>>> inverter = huawei_solar.HuaweiSolar('192.168.8.1')
>>> inverter.get("nb_optimizers")
could not read register value, is an other device already connected?
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python38\lib\site-packages\huawei_solar\huawei_solar.py", line 37, in get
    response = read_register(self.client, reg.register, reg.length)
  File "C:\Python38\lib\site-packages\huawei_solar\huawei_solar.py", line 151, in read_register
    raise ReadException(message)
huawei_solar.huawei_solar.ReadException: could not read register value, is an other device already connected?
>>> inverter.get("model_name")
Result(value='SUN2000-8KTL-M0', unit=None)
>>>

It seems like we’re getting somewhere, I think your device does not support optimizers and instead of returning 0 it just fails.
Any of these that fail?

inverter.get("active_power").value
inverter.get("daily_yield_energy").value
inverter.get("accumulated_yield_energy").value
inverter.get("reactive_power").value
inverter.get("power_factor").value
inverter.get("efficiency").value
inverter.get("grid_voltage").value
inverter.get("grid_current").value
inverter.get("grid_frequency").value
inverter.get("startup_time").value.time()
inverter.get("shutdown_time").value.time()
inverter.get("internal_temperature").value
inverter.get("device_status").value
inverter.get("nb_online_optimizers").value
inverter.get("day_active_power_peak").value

import huawei_solar
inverter = huawei_solar.HuaweiSolar(‘192.168.8.1’)
inverter.get(“active_power”).value
1793
inverter.get(“daily_yield_energy”).value
0.04
inverter.get(“accumulated_yield_energy”).value
31.27
inverter.get(“reactive_power”).value
1
inverter.get(“power_factor”).value
1.0
inverter.get(“efficiency”).value
96.92
inverter.get(“grid_voltage”).value
424.9
inverter.get(“grid_current”).value
2.487
inverter.get(“grid_frequency”).value
49.99
inverter.get(“startup_time”).value.time()
datetime.time(14, 16, 8)
inverter.get(“shutdown_time”).value.time()
datetime.time(18, 11, 39)
inverter.get(“internal_temperature”).value
16.7
inverter.get(“device_status”).value
‘On-grid’
inverter.get(“nb_online_optimizers”).value
could not read register value, is an other device already connected?
Traceback (most recent call last):
File “”, line 1, in
File “C:\Python38\lib\site-packages\huawei_solar\huawei_solar.py”, line 37, in get
response = read_register(self.client, reg.register, reg.length)
File “C:\Python38\lib\site-packages\huawei_solar\huawei_solar.py”, line 151, in read_register
raise ReadException(message)
huawei_solar.huawei_solar.ReadException: could not read register value, is an other device already connected?
inverter.get(“day_active_power_peak”).value
0

I will edit the code so that it assumes 0/NA on a fail. Where do you live that the grid voltage is 425V? :thinking:

Once github is back working again i’ll be trying to use this script as well!!

I would be on that voltage as well as i have a 3phase inverter… Do you think you script will work on that… as i know there is 3 outputs for grid voltage, grid current etc…

It’s not grid voltage, but voltage between L1 and L2. It’s working now, after I commented lines with optimizers in sensor.py. Inverter have L1, L2 and L3 so I will need some modification. Now I know how to do it. Thanks for your help.

Ahhh you have the 3-phase model like me! and my reply above…
So yes we will both need this modifications!

And because of the sun2000 have to be connected directly, I will need another AP in client mode and do some routing to home network or connect second lan cable to NAS. The 502 port looks closed on Smart dongle.

You could ask on the Huawei forum what’s up with that, I don’t think it’s supposed to be like that. They seem to be responsive to questions about firmware issues.

I will edit the integration so that it works on 3 phase and on 1 phase.

I asked them. https://forum.huawei.com/enterprise/en/modbus-tcp-connection-from-home-network-sun2000-8ktl-m0/thread/615790-100027
My English is not perfect but If I correctly understood it is the way it should be.

1 Like

I don’t think it is, on my device it works just fine by connecting via the ip address it gets from my router. Lets see if they say anything else. What do you mean by smart dongle?

Inverter has build in wifi working as Access point and you can only change password. If you want connect it to internet you need extra adapter (smart dongle). With this you can connect it to home network. So you have 2 wifi adapters in inverter (one is build in and second is external). Manual page 5 https://solar.huawei.com/en-GB/download?p=%2F-%2Fmedia%2FSolar%2Fattachment%2Fpdf%2Fau%2Fservice%2Fcommercial%2FSUN2000-8-20KTL-M0-User_Manual.pdf

Ah, my SUN2000L 3KTL doesn’t have that so the difference may lie there