huawei_solar: Can't get your component to work

I have an Huawei SUN2000-4KTL-M1 Home Assistant errors:

Logger: pymodbus.client.sync
Source: /usr/local/lib/python3.8/site-packages/pymodbus/client/sync.py:214
First occurred: 12:04:15 (2 occurrences)
Last logged: 12:04:17

Connection to (192.168.89.206, 502) failed: [Errno 111] Connection refused
Logger: huawei_solar.huawei_solar
Source: /usr/local/lib/python3.8/site-packages/huawei_solar/huawei_solar.py:171
First occurred: 12:04:17 (1 occurrences)
Last logged: 12:04:17

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 169, 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 107, in execute
    raise ConnectionException("Failed to connect[%s]" % (self.__str__()))
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.89.206:502)]
Logger: homeassistant.components.sensor
Source: custom_components/huawei_solar/sensor.py:124
Integration: Sensor (documentation, issues)
First occurred: 12:04:17 (1 occurrences)
Last logged: 12:04:17

Error while setting up huawei_solar platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/huawei_solar/huawei_solar.py", line 169, 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 107, in execute
    raise ConnectionException("Failed to connect[%s]" % (self.__str__()))
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.89.206:502)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 200, in _async_setup_platform
    await asyncio.shield(task)
  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 109, in setup_platform
    HuaweiSolarSensor(inverter, config[CONF_OPTIMIZERS], config[CONF_BATTERY])
  File "/config/custom_components/huawei_solar/sensor.py", line 124, in __init__
    self._name = self._inverter.get("model_name").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 172, in read_register
    raise ConnectionException(ex)
huawei_solar.huawei_solar.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.89.206:502)]

Errors in command line

❯ python3
Python 3.9.1 (default, Dec 10 2020, 11:11:14)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import huawei_solar
>>> inverter = huawei_solar.HuaweiSolar('192.168.89.206')
>>> inverter.get("model_name")
failed to connect to device, is the host correct?
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 169, in read_register
    response = self.client.read_holding_registers(register, length)
  File "/usr/local/lib/python3.9/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers
    return self.execute(request)
  File "/usr/local/lib/python3.9/site-packages/pymodbus/client/sync.py", line 107, in execute
    raise ConnectionException("Failed to connect[%s]" % (self.__str__()))
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.89.206:502)]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 169, in read_register
    response = self.client.read_holding_registers(register, length)
  File "/usr/local/lib/python3.9/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers
    return self.execute(request)
  File "/usr/local/lib/python3.9/site-packages/pymodbus/client/sync.py", line 107, in execute
    raise ConnectionException("Failed to connect[%s]" % (self.__str__()))
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.89.206:502)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/huawei_solar/huawei_solar.py", line 40, in get
    response = self.read_register(reg.register, reg.length)
  File "/usr/local/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] Failed to connect[ModbusTcpClient(192.168.89.206:502)]
>>>
❯ ping 192.168.89.206
PING 192.168.89.206 (192.168.89.206): 56 data bytes
64 bytes from 192.168.89.206: icmp_seq=0 ttl=255 time=2.485 ms
64 bytes from 192.168.89.206: icmp_seq=1 ttl=255 time=1.194 ms
64 bytes from 192.168.89.206: icmp_seq=2 ttl=255 time=1.252 ms
64 bytes from 192.168.89.206: icmp_seq=3 ttl=255 time=1.497 ms
64 bytes from 192.168.89.206: icmp_seq=4 ttl=255 time=1.246 ms
64 bytes from 192.168.89.206: icmp_seq=5 ttl=255 time=2.199 ms
64 bytes from 192.168.89.206: icmp_seq=6 ttl=255 time=1.943 ms

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 29 (10 by maintainers)

Most upvoted comments

Ok, give me some time. I just found out it’s possible to install requirements from git, so I think I will just make it async first and see if that solves the issue.