wills106 / homeassistant-solax-modbus

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

[BUG] error reading input registers at device 1 position 0x8166 #197

Closed vizkoze closed 1 year ago

vizkoze commented 1 year ago

Describe the bug Recently started using this plugin with my solis RHI-5K-48ES-5G after changing the serialnumber in the plugin_solis.py my instance started working.

Most of the entities are populated but i get one error in the log: 2022-11-09 16:31:20.570 ERROR (MainThread) [custom_components.solax_modbus] SolisModbus error reading input registers at device 1 position 0x8166

Mandatory details

  1. Integration Version: 33cc775
  2. HA Version: Home Assistant 2022.11.2 / Supervisor 2022.10.2 / Operating System 9.3 / Frontend 20221108.0 - latest
  3. Inverter Brand: SOLIS
  4. Plugin Used: solis
  5. First 6 digits of Serial: 103104 (updated manually)
  6. Connection Method: TCP on port 8899

Detailed Error Log 2022-11-09 16:31:20.570 ERROR (MainThread) [custom_components.solax_modbus] SolisModbus error reading input registers at device 1 position 0x8166

Additional context tried reading the plugin_solis.py for 8166 reference but there is none. When viewing the history graph, there might be a problem with reading the Inverter Voltage, the active power, or the inverter current wich turns to 0 or something like that.

wills106 commented 1 year ago

Do you have a Modbus Power Meter like one from Acrel or Estron SDM. Or are you just using CT Clamps?

vizkoze commented 1 year ago

I use the solis DLS-L lan stick that is directly connected to the inverter. Maybe there was an intermittant error due to starting/stopping the homeassistant instance for testing purposes. However now that the logging stick is offline due to the sun beeing under, an other error occurs: the plugin cannot connect anymore and tries every 2.5minutes to reconnect. Maybe a limit on how many times the connection should be retried could be implemented? like 15 minutes after sunset stop polling and 10 minutes befor sunrise start polling for the stick? Edit: i notice that the last known value is retained. In my instance, i monitor PV total power and after sunset it remains at 13W. It is the same behaviour I noticed when using the Ginlong Solis PV portal integration. Would i be trivial to set the value of instant power to 0?

Log: 2022-11-09 17:44:31.076 ERROR (MainThread) [custom_components.solax_modbus] SolisModbus error reading holding registers at device 1 position 0xa86c NoneType: None 2022-11-09 17:46:14.188 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 17:46:14.194 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 17:48:44.204 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 17:48:44.207 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 17:51:14.220 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 17:51:14.224 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 17:53:44.237 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 17:53:44.240 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 17:56:14.189 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 17:56:14.192 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 17:58:44.269 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 17:58:44.272 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 18:01:14.221 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 18:01:14.224 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 18:03:44.237 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 18:03:44.240 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 18:06:14.253 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 18:06:14.257 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 18:08:44.269 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 18:08:44.272 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)] 2022-11-09 18:11:14.285 ERROR (MainThread) [pymodbus.client.sync] Connection to (192.168.1.43, 8899) failed: [Errno 113] Host is unreachable 2022-11-09 18:11:14.289 ERROR (MainThread) [custom_components.solax_modbus] Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]: SolisModbus cannot read holding registers at device 1 position 0xa86c Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 332, in read_modbus_block else: realtime_data = self.read_holding_registers(unit=self._modbus_addr, address=block.start, count=block.end - block.start) File "/config/custom_components/solax_modbus/init.py", line 271, in read_holding_registers return self._client.read_holding_registers(address, count, **kwargs) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/common.py", line 114, in read_holding_registers return self.execute(request) File "/usr/local/lib/python3.10/site-packages/pymodbus/client/sync.py", line 108, in execute raise ConnectionException("Failed to connect[%s]" % (self.str())) pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.1.43:8899)]

wills106 commented 1 year ago

There is code to reduce reading when an Inverter goes to sleep to prevent slowdown of HA.

We thought of making the Integration respond invalid instead of the last read value, but would that mess up the long term stats etc?

If there is nothing to communicate to at all it's hard to work around that. All you can really do is not restart HA when your Inverter is asleep. I take it you don't have any batteries connected to your Inverter?

vizkoze commented 1 year ago

Don't have batteries connected to the inverter. Thanks for your work, I prefer your solution that keeps data local as soliscloud keeps messing up their api access and doesn't refresh as often.

infradom commented 1 year ago

Not sure I read everything correctly; went quickly over it. We could catch the error messages and just be silent during the dark hours but continue to try to reconnect at a slow pace. This would make debugging for other users difficult.