wills106 / homeassistant-solax-modbus

SolaX Power Modbus custom_component for Home Assistant (Supports some AlphaESS, Growatt, Sofar, Solinteg, Solis, SRNE, Swatten)
315 stars 101 forks source link

[Bug]: Integration causes user interface hangs when reading Modbus data #731

Closed Zwer2k closed 8 months ago

Zwer2k commented 8 months ago

Describe the bug

Every time the Modbus data is read out, the Homeassistant UI hangs for a few seconds, which is very annoying. Events from devices are also delayed. If the integration is deactivated, the error disappears. The problem occurs both in the live system and in the HA development environment. It looks like the method self._client.read_holding_registers() is responsible.

I suspect that the library must be used as async to fix this. from pymodbus.client import AsyncModbusTcpClient, AsyncModbusSerialClient

Integration Version

2024.02.1

Homeassistant core version

2024.2.0

Inverter brand

Sofar Solar HYD 10KTL-3ph

Plugin used

plugin_sofar.py

Serial prefix

SP2ES110

Connection Method

RS485-TCP with Waveshare TCP Adapter

Detailed Error Log

No response

Additional context

No response

wills106 commented 8 months ago

I have just updated from HA 2024.1.6 to HA 2024.2.1 without issue. Apart from a warning for commented out code in config_flow.py which has been addressed in 2024.02.2

Does the Integration develop any errors in the logs? How quick are you trying to poll the Inverter?

Zwer2k commented 8 months ago

Apart from the warning about custom integration, I don't get any errors or warnings from Solax Integration. I have already tried different speeds 9600, 57000 baud and others. The problem also existed with older versions of HA and the integration. My HA runs as a VM under Proxmox with an i5-8250U CPU. Should actually be better than a suitable Raspberry Pi 4.

wills106 commented 8 months ago

The baud rate needs to match whatever is on the Inverter LCD.

I was referring to the polling rate, when you setup the Integration.

image

Edit:

Have you set Modbus Gateway Type to "Auto query storage type" as per https://homeassistant-solax-modbus.readthedocs.io/en/latest/modbus-adaptor-setup/#waveshare-rs485-to-eth-b

Zwer2k commented 8 months ago

The baud rate has of course been set both in the integration and in the inverter. The pulling interval is set to 15 sec. But I have already tested with 30 sec. Then the problem occurs correspondingly less frequently. Modbus Gateway Type is set to "Auto query storage type"

cschlipf commented 8 months ago

No solution, but I can just add that I cannot reproduce this with a HYD 10 KTL 3PH, which is connected using ModBus TCP to a LSE-3 logger stick on a Rasperry PI4 at 15s polling interval.

fische11 commented 8 months ago

I sldo have this issue while using an LSE-3 LAN Stick Logger with an HYD 10 KTL 3PH. I also get these error logs. Do I need to change the ba on the inverter for the LSE-3 LAN Stick Logger?

2024-02-21 00:20:30.493 INFO (MainThread) [custom_components.solax_modbus] read_error : Sofar01 cannot read holding registers at device 1 position 0x584
NoneType: None
2024-02-21 00:20:30.494 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
2024-02-21 00:22:58.420 INFO (MainThread) [custom_components.solax_modbus] read_error : Sofar01 cannot read holding registers at device 1 position 0x404
NoneType: None
2024-02-21 00:22:58.420 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
2024-02-21 00:25:05.549 ERROR (MainThread) [homeassistant.components.hassio.handler] Timeout on /store request
2024-02-21 00:25:05.550 ERROR (MainThread) [homeassistant.components.hassio] Failed to to call /store - 
2024-02-21 00:28:14.499 INFO (MainThread) [custom_components.solax_modbus] read_error : Sofar01 cannot read holding registers at device 1 position 0x445
NoneType: None
2024-02-21 00:28:14.499 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
2024-02-21 00:30:58.637 INFO (MainThread) [custom_components.solax_modbus] read_error : Sofar01 cannot read holding registers at device 1 position 0x605
NoneType: None
2024-02-21 00:30:58.638 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
2024-02-21 00:32:18.659 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
Zwer2k commented 8 months ago

Is fixed. @wills106 thanks for the merge and the great integration.