wlcrs / huawei_solar

Home Assistant integration for Huawei Solar inverters via Modbus
GNU Affero General Public License v3.0
517 stars 80 forks source link

[Bug]: Unable to connect via serial on 1.2.0b5 1.1.6 is working #233

Closed be04376 closed 1 year ago

be04376 commented 1 year ago

Describe the issue

Upgrading to 1.2.0b5 cause connectivity issues over serial. Tried to complete remove and reinstall the integration, but then I'm unble to setup because huawei_solar.exceptions.ReadException: Failed to read register 43006 after 6 tries

added diagnostics file from 1.1.6

Bescribe your Huawei Solar Setup

Inverter Type: SUN2000-4.6KTL-L1 Inverter Firmware version: V200R001C00SPC125 SDongle present: no Power meter present: single phase Battery: LUNA2000 10kWh Battery Firmware version: V100R002C00SPC116

How do you connect to the inverter?

Over serial, with a serial-to-USB stick

Upload your Diagnostics File

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2022.12.8", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.7", "docker": true, "arch": "aarch64", "timezone": "Europe/Brussels", "os_name": "Linux", "os_version": "5.15.80", "supervisor": "2022.12.1", "host_os": "Home Assistant OS 9.4", "docker_version": "20.10.19", "chassis": "embedded", "run_as_root": true }, "custom_components": { "eufy_security": { "version": "2.10.0", "requirements": [ "websocket-client==1.1.0" ] }, "solcast_solar": { "version": "3.0.30", "requirements": [ "aiohttp>=3.6.2", "datetime>=4.3", "isodate>=0.6.0" ] }, "smartthinq_sensors": { "version": "0.27.1", "requirements": [ "pycountry>=20.7.3", "xmltodict>=0.12.0", "cchardet>=2.1.7" ] }, "huawei_solar": { "version": "1.1.6", "requirements": [ "huawei-solar==2.1.6" ] }, "nordpool": { "version": "0.0.9", "requirements": [ "nordpool>=0.2" ] }, "entsoe": { "version": "0.0.1", "requirements": [ "entsoe-py==0.5.8" ] }, "hacs": { "version": "1.29.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "skodaconnect": { "version": "v1.1.4", "requirements": [ "skodaconnect>=1.2.5", "homeassistant>=2022.12.0" ] }, "webrtc": { "version": "v2.3.1", "requirements": [] }, "afvalbeheer": { "version": "5.0.10", "requirements": [ "rsa", "pycryptodome" ] } }, "integration_manifest": { "domain": "huawei_solar", "name": "Huawei Solar", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/huawei_solar", "issue_tracker": "https://github.com/wlcrs/huawei_solar/issues", "requirements": [ "huawei-solar==2.1.6" ], "codeowners": [ "@wlcrs" ], "iot_class": "local_polling", "version": "1.1.6", "loggers": [ "huawei_solar", "pymodbus" ], "is_built_in": false }, "data": { "config_entry_data": { "host": null, "port": "/dev/serial/by-id/usb-1a86USB2.0-Ser-if00-port0", "slave_ids": [ 1 ], "enable_parameter_configuration": true, "username": null, "password": null }, "slave_0": { "model_name": "SUN2000-4.6KTL-L1", "pv_string_count": 2, "has_optimizers": 0, "battery_1_type": 2, "battery_2_type": 0, "power_meter_type": 0 }, "slave_0_data": { "input_power": [ 490, "W" ], "line_voltage_A_B": [ 239.9, "V" ], "line_voltage_B_C": [ 0.0, "V" ], "line_voltage_C_A": [ 0.0, "V" ], "phase_A_voltage": [ 241.1, "V" ], "phase_B_voltage": [ 0.2, "V" ], "phase_C_voltage": [ 0.0, "V" ], "phase_A_current": [ 1.873, "A" ], "phase_B_current": [ 0.0, "A" ], "phase_C_current": [ 0.0, "A" ], "day_active_power_peak": [ 5000, "W" ], "active_power": [ 444, "W" ], "reactive_power": [ -1, "VA" ], "power_factor": [ 1.0, null ], "grid_frequency": [ 49.98, "Hz" ], "efficiency": [ 100.0, "%" ], "internal_temperature": [ 34.2, "\u00b0C" ], "insulation_resistance": [ 30.0, "MOhm" ], "device_status": [ "On-grid", null ], "fault_code": [ 0, null ], "startup_time": [ "2023-01-03T09:01:08+00:00", null ], "shutdown_time": [ null, null ], "accumulated_yield_energy": [ 12169.44, "kWh" ], "daily_yield_energy": [ 9.18, "kWh" ], "state_1": [ [ "Grid-Connected", "Grid-Connected normally" ], null ], "state_2": [ [ "Unlocked", "PV connected", "DSP data collection" ], null ], "state_3": [ [ "On-grid", "Off-grid switch disabled" ], null ], "alarm_1": [ [], null ], "alarm_2": [ [], null ], "alarm_3": [ [], null ], "pv_01_voltage": [ 317.2, "V" ], "pv_01_current": [ 0.81, "A" ], "pv_02_voltage": [ 317.3, "V" ], "pv_02_current": [ 0.81, "A" ], "grid_A_voltage": [ 239.6, "V" ], "grid_B_voltage": [ null, "V" ], "grid_C_voltage": [ null, "V" ], "active_grid_A_current": [ 1.31, "I" ], "active_grid_B_current": [ null, "I" ], "active_grid_C_current": [ null, "I" ], "power_meter_active_power": [ 4, "W" ], "power_meter_reactive_power": [ 315, "Var" ], "active_grid_power_factor": [ 0.03, null ], "active_grid_frequency": [ 49.97, "Hz" ], "grid_exported_energy": [ 3707.79, "kWh" ], "grid_accumulated_energy": [ 6288.2, "kWh" ], "grid_accumulated_reactive_power": [ 58.52, "kVarh" ], "meter_type": [ 0, null ], "active_grid_A_B_voltage": [ null, "V" ], "active_grid_B_C_voltage": [ null, "V" ], "active_grid_C_A_voltage": [ null, "V" ], "active_grid_A_power": [ null, "W" ], "active_grid_B_power": [ null, "W" ], "active_grid_C_power": [ null, "W" ], "storage_state_of_capacity": [ 30.0, "%" ], "storage_running_status": [ 2, null ], "storage_bus_voltage": [ 439.2, "V" ], "storage_bus_current": [ 0.0, "A" ], "storage_charge_discharge_power": [ 46, "W" ], "storage_total_charge": [ 3501.0, "kWh" ], "storage_total_discharge": [ 3423.02, "kWh" ], "storage_current_day_charge_capacity": [ 0.43, "kWh" ], "storage_current_day_discharge_capacity": [ 7.58, "kWh" ] } } }

Upload your relevant debug logs

2023-01-03 17:20:10.469 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.load_1m (None) can not be converted to the unit of previously compiled statistics ( ). Generation of long term statistics will be suppressed unless the unit changes back to   or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this
2023-01-03 17:20:10.473 INFO (Recorder) [homeassistant.components.sensor.recorder] Detected new cycle for sensor.energy_consumption_tarif_1_cost, last_reset set to 2023-01-03T16:16:04.453614+00:00 (old last_reset 2023-01-03T16:13:54.830668+00:00)
2023-01-03 17:20:10.474 INFO (Recorder) [homeassistant.components.sensor.recorder] Detected new cycle for sensor.energy_consumption_tarif_2_cost, last_reset set to 2023-01-03T16:16:04.454166+00:00 (old last_reset 2023-01-03T16:13:54.832073+00:00)
2023-01-03 17:20:10.474 INFO (Recorder) [homeassistant.components.sensor.recorder] Detected new cycle for sensor.energy_production_tarif_1_compensation, last_reset set to 2023-01-03T16:16:04.454431+00:00 (old last_reset 2023-01-03T16:13:54.833265+00:00)
2023-01-03 17:20:10.474 INFO (Recorder) [homeassistant.components.sensor.recorder] Detected new cycle for sensor.energy_production_tarif_2_compensation, last_reset set to 2023-01-03T16:16:04.454676+00:00 (old last_reset 2023-01-03T16:13:54.835335+00:00)
2023-01-03 17:20:10.474 INFO (Recorder) [homeassistant.components.sensor.recorder] Detected new cycle for sensor.gas_consumption_cost, last_reset set to 2023-01-03T16:16:04.454919+00:00 (old last_reset 2023-01-03T16:13:54.836662+00:00)
2023-01-03 17:20:24.466 DEBUG (MainThread) [pymodbus.client.serial] Starting serial connection
2023-01-03 17:20:24.468 DEBUG (MainThread) [pymodbus.client.base] Client connected to modbus server
2023-01-03 17:20:24.468 INFO (MainThread) [pymodbus.client.serial] Serial connected.
2023-01-03 17:20:24.468 INFO (MainThread) [pymodbus.client.serial] Connected to /dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0
2023-01-03 17:20:24.469 DEBUG (MainThread) [huawei_solar.huawei_solar] Reading register 43006
2023-01-03 17:20:24.469 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e
2023-01-03 17:20:24.469 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1
2023-01-03 17:20:27.470 INFO (MainThread) [backoff] Backing off _do_read(...) for 1.0s (asyncio.exceptions.TimeoutError)
2023-01-03 17:20:27.471 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 1.0 seconds after 1 tries
2023-01-03 17:20:28.472 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e
2023-01-03 17:20:28.473 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1
2023-01-03 17:20:31.475 INFO (MainThread) [backoff] Backing off _do_read(...) for 2.0s (asyncio.exceptions.TimeoutError)
2023-01-03 17:20:31.475 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 2.0 seconds after 2 tries
2023-01-03 17:20:33.475 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e
2023-01-03 17:20:33.476 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1
2023-01-03 17:20:36.478 INFO (MainThread) [backoff] Backing off _do_read(...) for 4.0s (asyncio.exceptions.TimeoutError)
2023-01-03 17:20:36.478 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 4.0 seconds after 3 tries
2023-01-03 17:20:40.480 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e
2023-01-03 17:20:40.481 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1
2023-01-03 17:20:43.484 INFO (MainThread) [backoff] Backing off _do_read(...) for 8.0s (asyncio.exceptions.TimeoutError)
2023-01-03 17:20:43.484 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 8.0 seconds after 4 tries
2023-01-03 17:20:51.486 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e
2023-01-03 17:20:51.488 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1
2023-01-03 17:20:54.490 INFO (MainThread) [backoff] Backing off _do_read(...) for 16.0s (asyncio.exceptions.TimeoutError)
2023-01-03 17:20:54.490 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 16.0 seconds after 5 tries
2023-01-03 17:21:03.523 INFO (SyncWorker_3) [roombapy.remote_client] Connecting to 192.168.0.158, attempt 1 of 3
2023-01-03 17:21:06.589 ERROR (SyncWorker_3) [roombapy.remote_client] Can't connect to 192.168.0.158, error: [Errno 113] Host is unreachable
2023-01-03 17:21:06.590 INFO (SyncWorker_3) [roombapy.remote_client] Connecting to 192.168.0.158, attempt 2 of 3
2023-01-03 17:21:09.661 ERROR (SyncWorker_3) [roombapy.remote_client] Can't connect to 192.168.0.158, error: [Errno 113] Host is unreachable
2023-01-03 17:21:09.662 INFO (SyncWorker_3) [roombapy.remote_client] Connecting to 192.168.0.158, attempt 3 of 3
2023-01-03 17:21:10.492 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e
2023-01-03 17:21:10.493 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1
2023-01-03 17:21:12.733 ERROR (SyncWorker_3) [roombapy.remote_client] Can't connect to 192.168.0.158, error: [Errno 113] Host is unreachable
2023-01-03 17:21:12.734 ERROR (SyncWorker_3) [roombapy.remote_client] Unable to connect to 192.168.0.158
2023-01-03 17:21:13.495 ERROR (MainThread) [backoff] Giving up _do_read(...) after 6 tries (asyncio.exceptions.TimeoutError)
2023-01-03 17:21:13.498 ERROR (MainThread) [huawei_solar.huawei_solar] Aborting client creation due to error.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, 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.10/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 276, in _do_read
    response = await self._client.protocol.read_holding_registers(
  File "/usr/local/lib/python3.10/site-packages/pymodbus/client/base.py", line 295, in execute
    resp = await asyncio.wait_for(req, timeout=self.params.timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 150, in create_rtu
    await huawei_solar._initialize()
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 85, in _initialize
    self.time_zone = (await self.get(rn.TIME_ZONE)).value
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 194, in get
    return (await self.get_multiple([name], slave))[0]
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 229, in get_multiple
    response = await self._read_registers(registers[0].register, total_length, slave)
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 309, in _read_registers
    result = await _do_read()
  File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 159, in retry
    await _call_handlers(on_giveup, **details, exception=e)
  File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 37, in _call_handlers
    await handler(details)
  File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 16, in f
    return coro_or_func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 255, 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

Please confirm the following:

wlcrs commented 1 year ago

Possibly related to https://github.com/riptideio/pymodbus/issues/1214 .

wlcrs commented 1 year ago

That issue is apparently fixed in the next release of pyModbus, I'll need wait until they releases a new version. Can I ping you to test again when that's the case?

I'll put of promoting the current beta to stable until the problem is confirmed to be resolved.

be04376 commented 1 year ago

Sure let me now when I can test for you.

bekovan commented 1 year ago

Just tuning in to see when the next update is arriving.

Seems in beta a lot of stuff was happening. Do you have somewere a writeout to the function of the new parameters?

Binda5000 commented 1 year ago

had the same issue with 1.2.0b7. But after going back to 1.1.6 it still says failed to connect.

Logger: huawei_solar.huawei_solar
Source: /usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py:160
First occurred: 11:22:45 (3 occurrences)
Last logged: 11:24:17

Aborting client creation due to error.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 154, in create_rtu
    await huawei_solar._initialize()
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 85, in _initialize
    self.time_zone = (await self.get(rn.TIME_ZONE)).value
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 198, in get
    return (await self.get_multiple([name], slave))[0]
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 233, in get_multiple
    response = await self._read_registers(registers[0].register, total_length, slave)
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 313, in _read_registers
    result = await _do_read()
  File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 278, in _do_read
    raise ConnectionException(message)
huawei_solar.exceptions.ConnectionException: Modbus client is not connected to the inverter.
wlcrs commented 1 year ago

This should be fixed in release 1.2.0. Can you please test again?

bekovan commented 1 year ago

1) installed 1.2.0 2) failed to het integration online : Retrying setup: Failed to read register 43006 after 6 tries 3) power cycle Home assistant & inverter 4) Retrying setup: Failed to read register 43006 after 6 tries 5) rollback to 1.1.6 working fine

SUN2000-3.68KTL-L1

ogger: huawei_solar.huawei_solar Source: /usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py:160 First occurred: 11:26:17 (3 occurrences) Last logged: 11:28:08

Aborting client creation due to error. Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, 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.10/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 282, in _do_read response = await self._client.protocol.read_holding_registers( File "/usr/local/lib/python3.10/site-packages/pymodbus/client/base.py", line 303, in execute resp = await asyncio.wait_for(req, timeout=self.params.timeout) File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 154, in create_rtu await huawei_solar._initialize() File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 85, in _initialize self.time_zone = (await self.get(rn.TIME_ZONE)).value File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 200, in get return (await self.get_multiple([name], slave))[0] File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 235, in get_multiple response = await self._read_registers(registers[0].register, total_length, slave) File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 314, in _read_registers result = await _do_read() File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 159, in retry await _call_handlers(on_giveup, *details, exception=e) File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 37, in _call_handlers await handler(details) File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 16, in f return coro_or_func(args, **kwargs) File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 261, 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

be04376 commented 1 year ago

Hi,

serial connection still fails with 1.2.0

2023-01-19 16:47:36.103 DEBUG (MainThread) [pymodbus.client.serial] Starting serial connection 2023-01-19 16:47:36.105 DEBUG (MainThread) [pymodbus.client.base] Client connected to modbus server 2023-01-19 16:47:36.105 INFO (MainThread) [pymodbus.client.serial] Serial connected. 2023-01-19 16:47:36.106 INFO (MainThread) [pymodbus.client.serial] Connected to /dev/serial/by-id/usb-1a86USB2.0-Ser-if00-port0 2023-01-19 16:47:37.108 DEBUG (MainThread) [huawei_solar.huawei_solar] Reading register 43006 2023-01-19 16:47:37.109 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e 2023-01-19 16:47:37.109 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1 2023-01-19 16:47:40.115 INFO (MainThread) [backoff] Backing off _do_read(...) for 1.0s (asyncio.exceptions.TimeoutError) 2023-01-19 16:47:40.115 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 1.0 seconds after 1 tries 2023-01-19 16:47:41.115 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e 2023-01-19 16:47:41.116 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1 2023-01-19 16:47:44.117 INFO (MainThread) [backoff] Backing off _do_read(...) for 2.0s (asyncio.exceptions.TimeoutError) 2023-01-19 16:47:44.118 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 2.0 seconds after 2 tries 2023-01-19 16:47:46.119 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e 2023-01-19 16:47:46.120 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1 2023-01-19 16:47:49.122 INFO (MainThread) [backoff] Backing off _do_read(...) for 4.0s (asyncio.exceptions.TimeoutError) 2023-01-19 16:47:49.122 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 4.0 seconds after 3 tries 2023-01-19 16:47:51.549 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: Radiator-bathroom window open with state topic: zigbee2mqtt/Radiator-bathroom. Payload: '{"auto_lock":"AUTO","away_mode":"OFF","away_preset_days":1,"away_preset_temperature":15,"battery_low":false,"boost_time":300,"child_lock":"LOCK","comfort_temperature":20,"current_heating_setpoint":25,"eco_temperature":15,"force":"close","holidays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":12,"minute":30,"temperature":15},{"hour":17,"minute":30,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"holidays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/20°C 22:00/15°C","linkquality":36,"local_temperature":15.5,"local_temperature_calibration":-1,"max_temperature":35,"min_temperature":5,"position":0,"preset":"manual","running_state":"idle","system_mode":"off","update":{"installed_version":87,"latest_version":87,"state":"idle"},"update_available":false,"valve_detection":null,"week":"5+2","window_detection":"OFF","window_detection_params":{"minutes":80,"temperature":91},"window_open":false,"workdays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":17,"minute":31,"temperature":20},{"hour":18,"minute":31,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"workdays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 17:31/20°C 18:31/20°C 22:00/15°C"}', template output: 'False', with value template 'Template("{{ value_json.window_open }}")' 2023-01-19 16:47:51.570 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: Radiator-bedroom3 window open with state topic: zigbee2mqtt/Radiator-bedroom3. Payload: '{"auto_lock":"AUTO","away_mode":"OFF","away_preset_days":1,"away_preset_temperature":15,"battery_low":false,"boost_time":300,"child_lock":"LOCK","comfort_temperature":20,"current_heating_setpoint":15,"eco_temperature":15,"force":"close","holidays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":12,"minute":30,"temperature":15},{"hour":17,"minute":30,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"holidays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/20°C 22:00/15°C","linkquality":45,"local_temperature":13.5,"local_temperature_calibration":-1,"max_temperature":35,"min_temperature":5,"position":0,"preset":"manual","running_state":"idle","system_mode":"off","update":{"installed_version":87,"latest_version":87,"state":"idle"},"update_available":false,"valve_detection":null,"week":"5+2","window_detection":"OFF","window_detection_params":{"minutes":249,"temperature":12},"window_open":false,"workdays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":12,"minute":30,"temperature":15},{"hour":17,"minute":30,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"workdays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/20°C 22:00/15°C"}', template output: 'False', with value template 'Template("{{ value_json.window_open }}")' 2023-01-19 16:47:51.595 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: Radiator-bedroom1 window open with state topic: zigbee2mqtt/Radiator-bedroom1. Payload: '{"auto_lock":"AUTO","away_mode":"OFF","away_preset_days":1,"away_preset_temperature":15,"battery_low":false,"boost_time":300,"child_lock":"LOCK","comfort_temperature":20,"current_heating_setpoint":15,"eco_temperature":15,"force":"close","holidays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":12,"minute":30,"temperature":15},{"hour":17,"minute":30,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"holidays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/20°C 22:00/15°C","linkquality":51,"local_temperature":8.5,"local_temperature_calibration":-1,"max_temperature":35,"min_temperature":5,"position":0,"preset":"manual","running_state":"idle","system_mode":"off","update":{"installed_version":87,"latest_version":87,"state":"idle"},"update_available":false,"valve_detection":null,"week":"5+2","window_detection":"OFF","window_detection_params":{"minutes":0,"temperature":10},"window_open":false,"workdays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":12,"minute":30,"temperature":15},{"hour":17,"minute":30,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"workdays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/20°C 22:00/15°C"}', template output: 'False', with value template 'Template("{{ value_json.window_open }}")' 2023-01-19 16:47:51.614 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: Radiator-bedroom2 window open with state topic: zigbee2mqtt/Radiator-bedroom2. Payload: '{"auto_lock":"AUTO","away_mode":"OFF","away_preset_days":1,"away_preset_temperature":15,"battery_low":false,"boost_time":300,"child_lock":"LOCK","comfort_temperature":20,"current_heating_setpoint":15,"eco_temperature":15,"force":"close","holidays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":12,"minute":30,"temperature":15},{"hour":17,"minute":30,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"holidays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/20°C 22:00/15°C","linkquality":36,"local_temperature":13.5,"local_temperature_calibration":-1,"max_temperature":35,"min_temperature":5,"position":0,"preset":"manual","running_state":"idle","system_mode":"off","update":{"installed_version":87,"latest_version":87,"state":"idle"},"update_available":false,"valve_detection":null,"week":"5+2","window_detection":"OFF","window_detection_params":{"minutes":250,"temperature":21},"window_open":false,"workdays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,"temperature":15},{"hour":11,"minute":30,"temperature":15},{"hour":12,"minute":30,"temperature":15},{"hour":17,"minute":30,"temperature":20},{"hour":22,"minute":0,"temperature":15}],"workdays_schedule":"06:00/20°C 08:00/15°C 11:30/15°C 12:30/15°C 17:30/20°C 22:00/15°C"}', template output: 'False', with value template 'Template("{{ value_json.window_open }}")' 2023-01-19 16:47:53.123 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e 2023-01-19 16:47:53.124 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1 2023-01-19 16:47:56.126 INFO (MainThread) [backoff] Backing off _do_read(...) for 8.0s (asyncio.exceptions.TimeoutError) 2023-01-19 16:47:56.126 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 8.0 seconds after 4 tries 2023-01-19 16:48:04.127 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e 2023-01-19 16:48:04.128 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1 2023-01-19 16:48:07.129 INFO (MainThread) [backoff] Backing off _do_read(...) for 16.0s (asyncio.exceptions.TimeoutError) 2023-01-19 16:48:07.129 DEBUG (MainThread) [huawei_solar.huawei_solar] Backing off reading for 16.0 seconds after 5 tries 2023-01-19 16:48:23.130 DEBUG (MainThread) [pymodbus.client.base] send: 0x1 0x3 0xa7 0xfe 0x0 0x1 0xc6 0x8e 2023-01-19 16:48:23.131 DEBUG (MainThread) [pymodbus.transaction] Adding transaction 1 2023-01-19 16:48:26.133 ERROR (MainThread) [backoff] Giving up _do_read(...) after 6 tries (asyncio.exceptions.TimeoutError) 2023-01-19 16:48:26.138 ERROR (MainThread) [huawei_solar.huawei_solar] Aborting client creation due to error. Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, 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.10/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 282, in _do_read response = await self._client.protocol.read_holding_registers( File "/usr/local/lib/python3.10/site-packages/pymodbus/client/base.py", line 303, in execute resp = await asyncio.wait_for(req, timeout=self.params.timeout) File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 154, in create_rtu await huawei_solar._initialize() File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 85, in _initialize self.time_zone = (await self.get(rn.TIME_ZONE)).value File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 200, in get return (await self.get_multiple([name], slave))[0] File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 235, in get_multiple response = await self._read_registers(registers[0].register, total_length, slave) File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 314, in _read_registers result = await _do_read() File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 159, in retry await _call_handlers(on_giveup, *details, exception=e) File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 37, in _call_handlers await handler(details) File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 16, in f return coro_or_func(args, **kwargs) File "/usr/local/lib/python3.10/site-packages/huawei_solar/huawei_solar.py", line 261, 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

wlcrs commented 1 year ago

I will need to recreate my serial test-setup again to test locally. This will take some time as it's somewhat inconveniently located for me. For now, revert to 1.1.6 (or ideally: dig in yourself to help me find the issue with the upgrade to pymodbus v3.1.0)

wlcrs commented 1 year ago

I'm having some trouble to get my serial test setup back online. I've already been swapping out components and wiring, restarting my inverter, bricking it by selecting 'sunspec' instead of 'modbus' in a settings menu and having to do a system reset as a result, etc.

So for now, I have already spent a few hours on this problem without any progress. I will continue to work on it when I have more time (hopefully this weekend). If someone with some Python experience wants to help with this issue, they can head over to https://gitlab.com/Emilv2/huawei-solar/-/tree/develop/ to fetch the latest huawei-solar lib code. The develop branch has the latest code (with the bug), the master branch contains the version used by v1.1.6 of this integration.

iH8c0ff33 commented 1 year ago

So for now, I have already spent a few hours on this problem without any progress. I will continue to work on it when I have more time (hopefully this weekend). If someone with some Python experience wants to help with this issue, they can head over to https://gitlab.com/Emilv2/huawei-solar/-/tree/develop/ to fetch the latest huawei-solar lib code. The develop branch has the latest code (with the bug), the master branch contains the version used by v1.1.6 of this integration.

Thanks for all your work with this integration, it's been really useful for me. I'll try to find the issue in the huawei-solar library and keep you updated if I make some useful progress.

iH8c0ff33 commented 1 year ago

@wlcrs The old pymodbus async client used a default baudrate of 9600 instead of the one specified in constants.py, but in version >3.0.0 this seems to be fixed and the new default is 19200.

This integration could just always use 9600 as baudrate (i.e. hardcode it in __get_rtu_client) or add a baudate entry in the HA config flow. I already applied the first solution as a temporary fix (I'm working on my HA instance from a remote location so can't change inverter settings easily) and it is currently working (on version 1.2.0), but if you'd like to I can make a PR to add the config entry.

wlcrs commented 1 year ago

Hey @iH8c0ff33 , thank you for identifying the issue!! I will hardcode it to 9600 for now, as this is the quickest fix.

wlcrs commented 1 year ago

Version 1.2.1 has been released, which should fix this issue.

be04376 commented 1 year ago

Version 1.2.1 does indeed fix this issue. Thx for the quick support !