homeassistant-solax-modbus icon indicating copy to clipboard operation
homeassistant-solax-modbus copied to clipboard

[Bug]: 'Sofar' - 'HYD KTL10-3PH' Some connection error - from time to time integration stops.

Open hubertozog opened this issue 11 months ago • 64 comments

Describe the bug

From time to time the integrtion stops. All data freez wont get updated. There is no any real error in logs. Integration just hangs... To make it work even reboot of HA wont help. Also on the inverter there is no RS485 icon. If i try to send some request by RS485 usb adapter via modpool all works. I dont have any idea what its the issue. Sometimes it work for 5 days, sometimes issue will occure after one day...

Integration Version

2024.03.1

Homeassistant core version

2024.3.0

Inverter brand

Sofar

Plugin used

plugin_sofar.py

Serial prefix

SP2ES110N

Connection Method

Waveshare adapter RS485 to ETH

Detailed Error Log

2024-03-13 17:44:30.798 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected

024-03-13 15:29:18.277 DEBUG (MainThread) [custom_components.solax_modbus] connect modbus 2024-03-13 15:29:24.535 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x445 NoneType: None 2024-03-13 15:29:24.536 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10 2024-03-13 15:29:24.536 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved

Additional context

No response

hubertozog avatar Mar 13 '24 17:03 hubertozog

@hubertozog is this the same as reported with #793 ?

Other question: Did you properly terminate the RS485 bus on the inverter side?

cschlipf avatar Mar 14 '24 11:03 cschlipf

@cschlipf No, today i changed the wire and also made the termination. Will see if that helps.

hubertozog avatar Mar 15 '24 14:03 hubertozog

Thanks for the update. A proper termination is absolutely necessary for reliable operation

cschlipf avatar Mar 15 '24 14:03 cschlipf

Same here. It's been working for months ... and after recent integration update >2024.03.1 it needed restart once per day. Yesterday after HA update >2024.3.1 it needs restart every 5 mins. I see Modbus reading registers error in the log (same as above)

ppiwowar avatar Mar 15 '24 21:03 ppiwowar

I did quick&dirty automation that reloads config of this automation every 5 mins. So I keep data consistency of my Sofar inverter. I hope this problem goes away with new version ... soon, P L E A S E.

ppiwowar avatar Mar 16 '24 08:03 ppiwowar

perhaps related: I use a LSE3 LAN Stick Logger on a SofarSolar HYD. Operation stops after a while (less 24h) with timeput messages:

2024-03-16 11:34:26.152 INFO (MainThread) [custom_components.solax_modbus] exception AsyncModbusTcpClient.close() got an unexpected keyword argument 'intern' : SofarSolar cannot read holding registers at device 1 position 0x404
NoneType: None
2024-03-16 11:34:26.154 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
2024-03-16 11:34:36.148 DEBUG (MainThread) [custom_components.solax_modbus] connect modbus
2024-03-16 11:34:46.160 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
2024-03-16 11:34:51.150 DEBUG (MainThread) [custom_components.solax_modbus] connect modbus
2024-03-16 11:35:06.151 DEBUG (MainThread) [custom_components.solax_modbus] connect modbus
2024-03-16 11:35:06.166 DEBUG (MainThread) [custom_components.solax_modbus] assuming sleep mode - slowing down by factor 10
202

Perhaps this repeated "slowing down" multipy up?

alias avatar Mar 16 '24 11:03 alias

@cschlipf @ppiwowar @alias

Ok, got some new info. I am not sure, but after update of ha, and correct termination with new good wire, its working even worst.... But one goodside its that if i reload integration its gonna work again all the time. @ppiwowar coudl you provide to me your automation?

Its works about 2-5 mins and link is down, on waveshare adapter link icon tunrs yellow. here are the error msgs

Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1181, in _call_connection_lost super()._call_connection_lost(exc) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 901, in _call_connection_lost self._protocol.connection_lost(exc) File "/usr/local/lib/python3.12/site-packages/pymodbus/transport/transport.py", line 288, in connection_lost self.close(intern=True) TypeError: AsyncModbusTcpClient.close() got an unexpected keyword argument 'intern'

2024-03-16 12:44:24.273 WARNING (MainThread) [asyncio] socket.send() raised exception. 2024-03-16 12:44:29.274 WARNING (MainThread) [asyncio] socket.send() raised exception. 2024-03-16 12:44:34.276 WARNING (MainThread) [asyncio] socket.send() raised exception. 2024-03-16 12:47:21.182 WARNING (MainThread) [asyncio] socket.send() raised exception. 2024-03-16 12:47:26.184 WARNING (MainThread) [asyncio] socket.send() raised exception.

Maybe that will help a little.

I also lookend and checked wireing with diffrent adapter - waveshare RS485 to usb and using modpoll - tried to read register and for 30 mint didnt have any communication error.

hubertozog avatar Mar 16 '24 11:03 hubertozog

I have the same problem https://github.com/wills106/homeassistant-solax-modbus/issues/807 after recent update it is necessary to restart several times a day because the communication freezes

vitjurasek avatar Mar 16 '24 13:03 vitjurasek

Which Firmware version do you guys have? With V110022 for example there is a known Modbus Problem that causes frequent hangs. With V110051 this is fixed.

BTW: From time from time I also see that values are not updated, but it always recovers itself. At the same time however EVCC does still update its values.

cschlipf avatar Mar 16 '24 13:03 cschlipf

Inverter:V110044 PCU:V010019 BDU:V010010 BMS:V010019

So i need to go with update right now...

hubertozog avatar Mar 16 '24 13:03 hubertozog

Ok even after update of sofar:

2024-03-16 15:24:29.344 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorSocketTransport._call_connection_lost(None) Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1181, in _call_connection_lost super()._call_connection_lost(exc) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 901, in _call_connection_lost self._protocol.connection_lost(exc) File "/usr/local/lib/python3.12/site-packages/pymodbus/transport/transport.py", line 288, in connection_lost self.close(intern=True) TypeError: AsyncModbusTcpClient.close() got an unexpected keyword argument 'intern' 2024-03-16 15:24:54.768 WARNING (MainThread) [asyncio] socket.send() raised exception. 2024-03-16 15:24:59.769 WARNING (MainThread) [asyncio] socket.send() raised exception. 2024-03-16 15:25:04.771 WARNING (MainThread) [asyncio] socket.send() raised exception. 2024-03-16 15:25:09.771 WARNING (MainThread) [asyncio] socket.send() raised exception.

Also is its possible to see in integraton data of 2 batteries connected to one BTS?

hubertozog avatar Mar 16 '24 14:03 hubertozog

With #797 you will be able to see the data of up to 8 batteries. Note however that in case of the BTS each BDU counts as one battery not matter how many BTS-5K modules are attached to that BDU. If you have connected two BDUs, then the second BDU will be shown as battery two.

In case of AMASS GTX3000, each module is counted as individual battery.

cschlipf avatar Mar 16 '24 15:03 cschlipf

I have just released 2024.03.2 which forces pyModbus to v3.6.6 v3.6.5 and v3.6.6 have quite a few fixes for various communication related issues by the look. I'm not getting any of these errors people are encounting so I don't know how much of an improvement v3.6.6 will make.

Edit: I would also recommend downloading the update through HACS removing the integration from the Integration page, restarting HA and adding it in again. To ensure there isn't any left over configuration prior to 2024.03.1 stored in the cache.

wills106 avatar Mar 16 '24 17:03 wills106

@wills106

Thanks for support! For me right now it looks a lot better.

I got:

024-03-16 18:32:49.916 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected 2024-03-16 18:33:00.318 WARNING (MainThread) [custom_components.solax_modbus.sensor] holding register already used: 0x104d bat_config_depth_of_discharge 2024-03-16 18:33:00.318 WARNING (MainThread) [custom_components.solax_modbus.sensor] holding register already used: 0x104e bat_config_end_of_discharge 2024-03-16 18:33:00.319 WARNING (MainThread) [custom_components.solax_modbus.sensor] holding register already used: 0x1055 bat_config_address_4

But that dont kill or freez the integration, it will come to live by its own so its a lot better than it was before. If its possible to gather any data that could be helpfull for you - feel free to ask.

hubertozog avatar Mar 16 '24 17:03 hubertozog

@wills106

Thanks for support! For me right now it looks a lot better.

I got:

024-03-16 18:32:49.916 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected 2024-03-16 18:33:00.318 WARNING (MainThread) [custom_components.solax_modbus.sensor] holding register already used: 0x104d bat_config_depth_of_discharge 2024-03-16 18:33:00.318 WARNING (MainThread) [custom_components.solax_modbus.sensor] holding register already used: 0x104e bat_config_end_of_discharge 2024-03-16 18:33:00.319 WARNING (MainThread) [custom_components.solax_modbus.sensor] holding register already used: 0x1055 bat_config_address_4

But that dont kill or freez the integration, it will come to live by its own so its a lot better than it was before. If its possible to gather any data that could be helpfull for you - feel free to ask.

The last three lines is another unrelated issue I just fixed with #810

cschlipf avatar Mar 16 '24 17:03 cschlipf

@wills106 , thank you a great deal! Your release 2024.03.2 works here like a charm for almost 12 hours.

ppiwowar avatar Mar 17 '24 08:03 ppiwowar

Can you give some feedback what happens, when you try to set values? E.g. try to change the Energy Storage Mode or try to change Battery Charge/Discharge powers. Does this work without errors for you?

In my case I am receiving errors since 2024.03. And I have problems setting some values like the Battery power values.

cschlipf avatar Mar 17 '24 09:03 cschlipf

@ppiwowar Do you have any errors like this? i got around 100 from yesterday till today :/

2024-03-17 14:40:28.774 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected

@cschlipf I got same issues, cant change Energy storage mode etc.

hubertozog avatar Mar 17 '24 13:03 hubertozog

Can you try 2024.03.3 I have added a check to see if the Inverter is connected and if it isn't then it try's and connects.

wills106 avatar Mar 17 '24 14:03 wills106

Sure, update in progress, gonna check is that help. Thanks for your hard work!!!

hubertozog avatar Mar 17 '24 14:03 hubertozog

@hubertozog , I am a newbie of HA. Where do I need to look for these errors, pls?

ppiwowar avatar Mar 17 '24 14:03 ppiwowar

@wills106 Unfortunatly still:

2024-03-17 15:33:41.225 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected

Gonna see how often it will appear.

@ppiwowar Settings -> System -> Logs

hubertozog avatar Mar 17 '24 14:03 hubertozog

https://homeassistant-solax-modbus.readthedocs.io/en/latest/faq/#detailed-error-log

wills106 avatar Mar 17 '24 14:03 wills106

@hubertozog are you getting anything like:

2024-03-17 14:41:02.230 INFO (MainThread) [custom_components.solax_modbus] Inverter is not connected, trying to connect
2024-03-17 14:41:02.370 INFO (MainThread) [custom_components.solax_modbus] Inverter connected at 192.168.x.x:502

In your logs? Or Unable to connect to Inverter at...

wills106 avatar Mar 17 '24 14:03 wills106

Thats all i got related to Solax integration:

2024-03-17 15:33:41.225 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 15:37:45.806 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected

hubertozog avatar Mar 17 '24 14:03 hubertozog

Do you have your logger set with info like in the link I posted a couple of posts ago?

wills106 avatar Mar 17 '24 14:03 wills106

Just setet it up like you told, gonna paste detailed log only when i got error.

EDIT:

2024-03-17 15:54:10.411 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x60b
NoneType: None
2024-03-17 15:54:10.411 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected

After that integration will work again. I dont need to do anything - just error, and after that all works again.

hubertozog avatar Mar 17 '24 14:03 hubertozog

@hubertozog , any errors in the log were by the time of installing 2024.03.2. No errors thenafter.

ppiwowar avatar Mar 17 '24 15:03 ppiwowar

@wills106 Heres error log. Hope that it will help.

2024-03-17 16:02:20.866 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 16:14:38.466 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x60b
NoneType: None
2024-03-17 16:14:38.466 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 16:18:43.073 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x404
NoneType: None
2024-03-17 16:18:43.073 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 16:22:48.499 INFO (MainThread) [custom_components.solax_modbus] Inverter is not connected, trying to connect
2024-03-17 16:22:55.440 INFO (MainThread) [custom_components.solax_modbus] Inverter connected at 10.100.x.x:502
2024-03-17 16:31:00.680 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x404
NoneType: None
2024-03-17 16:31:00.680 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 16:35:05.290 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x1029
NoneType: None
2024-03-17 16:35:05.291 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 16:55:33.161 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x5c4
NoneType: None
2024-03-17 16:55:33.161 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 16:55:33.632 INFO (MainThread) [custom_components.solax_modbus] Inverter is not connected, trying to connect
2024-03-17 16:55:34.855 INFO (MainThread) [custom_components.solax_modbus] Inverter connected at 10.100.x.x:502
2024-03-17 17:16:00.978 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x484
NoneType: None
2024-03-17 17:16:00.978 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 17:20:08.130 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x404
NoneType: None
2024-03-17 17:20:08.131 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 17:28:18.457 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x60b
NoneType: None
2024-03-17 17:28:18.457 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 17:28:18.755 INFO (MainThread) [custom_components.solax_modbus] Inverter is not connected, trying to connect
2024-03-17 17:28:19.789 INFO (MainThread) [custom_components.solax_modbus] Inverter connected at 10.100.x.x:502
2024-03-17 17:44:40.482 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x504
NoneType: None
2024-03-17 17:44:40.482 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 17:52:53.414 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x484
NoneType: None
2024-03-17 17:52:53.414 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected
2024-03-17 18:01:03.887 INFO (MainThread) [custom_components.solax_modbus] Inverter is not connected, trying to connect
2024-03-17 18:01:25.842 INFO (MainThread) [custom_components.solax_modbus] Inverter connected at 10.100.x.x:502
2024-03-17 18:09:15.420 INFO (MainThread) [custom_components.solax_modbus] exception 'NoneType' object has no attribute 'write' : Sofar cannot read holding registers at device 1 position 0x100a
NoneType: None
2024-03-17 18:09:15.421 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Client is not connected

hubertozog avatar Mar 17 '24 17:03 hubertozog

Those who have problems. Can you show your settings of Waveshare RS485 to ETH adapter?

Zwer2k avatar Mar 17 '24 21:03 Zwer2k