wills106 / homeassistant-solax-modbus

SolaX Power Modbus custom_component for Home Assistant (Supports some Ginlong Solis, Growatt, Sofar Solar, TIGO TSI & Qcells Q.Volt Hyb)
282 stars 85 forks source link

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

Open hubertozog opened 3 months ago

hubertozog commented 3 months ago

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

cschlipf commented 3 months ago

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

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

hubertozog commented 3 months ago

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

cschlipf commented 3 months ago

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

ppiwowar commented 3 months ago

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 commented 3 months ago

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.

alias commented 3 months ago

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?

hubertozog commented 3 months ago

@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.

vitjurasek commented 3 months ago

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

cschlipf commented 3 months ago

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.

hubertozog commented 3 months ago

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

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

hubertozog commented 3 months ago

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?

cschlipf commented 3 months ago

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.

wills106 commented 3 months ago

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.

hubertozog commented 3 months ago

@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.

cschlipf commented 3 months ago

@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

ppiwowar commented 3 months ago

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

cschlipf commented 3 months ago

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.

hubertozog commented 3 months ago

@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.

wills106 commented 3 months ago

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.

hubertozog commented 3 months ago

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

ppiwowar commented 3 months ago

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

hubertozog commented 3 months ago

@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

wills106 commented 3 months ago

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

wills106 commented 3 months ago

@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...

hubertozog commented 3 months ago

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
wills106 commented 3 months ago

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

hubertozog commented 3 months ago

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.

ppiwowar commented 3 months ago

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

hubertozog commented 3 months ago

@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
Zwer2k commented 3 months ago

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

hubertozog commented 3 months ago

I found a copy of HA without solax integration, made recovery from it. Reinstalled integration again. Setted up all again and i will see how it will work. Zrzut ekranu 2024-03-18 144157 Zrzut ekranu 2024-03-18 144314

Zwer2k commented 3 months ago

image My settings are slightly different. I have no problems at all. You can perhaps test my settings

hubertozog commented 3 months ago

For right now after about 10 hours, after fresh install and Zwer2k Waveshare settings - no error or any messeage right now. Will check if anything will happen in next few days - but i hope so that everything its ok right now :)

cschlipf commented 3 months ago

What about changing values like the Energy Storage Mode?

hubertozog commented 3 months ago

Unfortuneatly not working, checket it few seconds ago.

2024-03-19 07:20:32.801 INFO (MainThread) [custom_components.solax_modbus.select] writing Sofar select register 4368 value 1
2024-03-19 07:20:58.157 INFO (MainThread) [custom_components.solax_modbus.select] *** local data written tou_charge_start_time: 1536
2024-03-19 07:21:03.181 INFO (MainThread) [custom_components.solax_modbus] saved modified persistent date: {'_version': 1, 'passive_mode_grid_power': 0, 'passive_mode_battery_power_min': 0, 'passive_mode_battery_power_max': 0, 'feedin_max_power': 0, 'timing_charge_power': 1000, 'timing_discharge_power': 1000, 'timing_id': 0.0, 'tou_id': 0, 'tou_target_soc': 0, 'tou_charge_power': 0, 'feedin_limitation_mode': 'Disabled', 'timing_charge': 'Disabled', 'timing_charge_start_time': None, 'timing_charge_end_time': None, 'timing_discharge_start_time': None, 'timing_discharge_end_time': None, 'tou_control': 'Enabled - Charging & Discharging', 'tou_charge_start_time': '06:00', 'tou_charge_end_time': '16:45', 'passive_mode_timeout': None, 'passive_mode_timeout_action': None}
2024-03-19 07:22:45.315 INFO (MainThread) [custom_components.solax_modbus.number] *** local data written tou_target_soc: 60.0
2024-03-19 07:22:48.165 INFO (MainThread) [custom_components.solax_modbus] saved modified persistent date: {'_version': 1, 'passive_mode_grid_power': 0, 'passive_mode_battery_power_min': 0, 'passive_mode_battery_power_max': 0, 'feedin_max_power': 0, 'timing_charge_power': 1000, 'timing_discharge_power': 1000, 'timing_id': 0.0, 'tou_id': 0, 'tou_target_soc': 60.0, 'tou_charge_power': 0, 'feedin_limitation_mode': 'Disabled', 'timing_charge': 'Disabled', 'timing_charge_start_time': None, 'timing_charge_end_time': None, 'timing_discharge_start_time': None, 'timing_discharge_end_time': None, 'tou_control': 'Enabled - Charging & Discharging', 'tou_charge_start_time': '06:00', 'tou_charge_end_time': '16:45', 'passive_mode_timeout': None, 'passive_mode_timeout_action': None}
2024-03-19 07:23:13.040 INFO (MainThread) [custom_components.solax_modbus.number] *** local data written tou_charge_power: 1300.0
2024-03-19 07:23:18.183 INFO (MainThread) [custom_components.solax_modbus] saved modified persistent date: {'_version': 1, 'passive_mode_grid_power': 0, 'passive_mode_battery_power_min': 0, 'passive_mode_battery_power_max': 0, 'feedin_max_power': 0, 'timing_charge_power': 1000, 'timing_discharge_power': 1000, 'timing_id': 0.0, 'tou_id': 0, 'tou_target_soc': 60.0, 'tou_charge_power': 1300.0, 'feedin_limitation_mode': 'Disabled', 'timing_charge': 'Disabled', 'timing_charge_start_time': None, 'timing_charge_end_time': None, 'timing_discharge_start_time': None, 'timing_discharge_end_time': None, 'tou_control': 'Enabled - Charging & Discharging', 'tou_charge_start_time': '06:00', 'tou_charge_end_time': '16:45', 'passive_mode_timeout': None, 'passive_mode_timeout_action': None}
2024-03-19 07:23:19.743 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140667539567040] None
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 139, in _async_press_action
await self.async_press()
File "/config/custom_components/solax_modbus/button.py", line 91, in async_press
await self._hub.async_write_registers_multi(
File "/config/custom_components/solax_modbus/__init__.py", line 476, in async_write_registers_multi
if hasattr(descr, 'reverse_option_dict'): value = descr.reverse_option_dict[value] # string to int
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
KeyError: None
2024-03-19 07:24:32.476 INFO (MainThread) [custom_components.solax_modbus.select] writing Sofar select register 4368 value 0
2024-03-19 07:25:03.191 INFO (MainThread) [custom_components.solax_modbus] saved modified persistent date: {'_version': 1, 'passive_mode_grid_power': 0, 'passive_mode_battery_power_min': 0, 'passive_mode_battery_power_max': 0, 'feedin_max_power': 0, 'timing_charge_power': 1000, 'timing_discharge_power': 1000, 'timing_id': 0.0, 'tou_id': 0, 'tou_target_soc': 0, 'tou_charge_power': 1300.0, 'feedin_limitation_mode': 'Disabled', 'timing_charge': 'Disabled', 'timing_charge_start_time': None, 'timing_charge_end_time': None, 'timing_discharge_start_time': None, 'timing_discharge_end_time': None, 'tou_control': 'Enabled - Charging & Discharging', 'tou_charge_start_time': '06:00', 'tou_charge_end_time': '16:45', 'passive_mode_timeout': None, 'passive_mode_timeout_action': None}
2024-03-19 07:25:33.172 INFO (MainThread) [custom_components.solax_modbus] saved modified persistent date: {'_version': 1, 'passive_mode_grid_power': 0, 'passive_mode_battery_power_min': 0, 'passive_mode_battery_power_max': 0, 'feedin_max_power': 0, 'timing_charge_power': 1000, 'timing_discharge_power': 1000, 'timing_id': 0.0, 'tou_id': 0, 'tou_target_soc': 0, 'tou_charge_power': 0, 'feedin_limitation_mode': 'Disabled', 'timing_charge': 'Disabled', 'timing_charge_start_time': None, 'timing_charge_end_time': None, 'timing_discharge_start_time': None, 'timing_discharge_end_time': None, 'tou_control': 'Enabled - Charging & Discharging', 'tou_charge_start_time': '06:00', 'tou_charge_end_time': '16:45', 'passive_mode_timeout': None, 'passive_mode_timeout_action': None}
andbad commented 3 months ago

After upgrading HA to version 2023.03.1, the integration crashed after a few minutes. To resolve this I went back to 2023.03.0. This morning I deleted the integration (deleting the directory under custom_components), downloaded and installed version 2023.03.6 of the component. I then updated HA to version 2023.03.1, and it has currently been working for about 30 minutes. After the startup, the only logs are the following:

2024-03-21 10:00:03.940 INFO (MainThread) [custom_components.solax_modbus] read_error : InverterZCS cannot read holding registers at device 1 position 0x1044
2024-03-21 10:00:04.811 WARNING (MainThread) [custom_components.solax_modbus] InverterZCS: read failed at 0x69a: battery_Output_energy_total 

By(t)e

andbad commented 3 months ago

:( While I was sending the previous message, the integration stopped updating the data. The last update are on 10.00 This is the last logs:

2024-03-21 10:04:50.728 ERROR (MainThread) [pymodbus.logging] Unable to decode response Modbus Error: Unknown response 0
2024-03-21 10:04:50.729 ERROR (MainThread) [homeassistant] Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
    self._protocol.data_received(data)
  File ".homeassistant/homeassistant/lib/python3.11/site-packages/pymodbus/transport/transport.py", line 303, in data_received
    self.datagram_received(data, None)
  File ".homeassistant/homeassistant/lib/python3.11/site-packages/pymodbus/transport/transport.py", line 337, in datagram_received
    cut = self.callback_data(self.recv_buffer, addr=addr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".homeassistant/homeassistant/lib/python3.11/site-packages/pymodbus/client/base.py", line 201, in callback_data
    self.framer.processIncomingPacket(data, self._handle_response, slave=0)
  File ".homeassistant/homeassistant/lib/python3.11/site-packages/pymodbus/framer/base.py", line 139, in processIncomingPacket
    self.frameProcessIncomingPacket(single, callback, slave, **kwargs)
  File ".homeassistant/homeassistant/lib/python3.11/site-packages/pymodbus/framer/socket_framer.py", line 104, in frameProcessIncomingPacket
    if (result := self.decoder.decode(data)) is None:
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pymodbus.exceptions.ModbusIOException: Modbus Error: [Input/Output] Unable to decode request
2024-03-21 10:04:50.739 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorSocketTransport._call_connection_lost(ModbusIOExcep...code request'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1117, in _call_connection_lost
    super()._call_connection_lost(exc)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 896, in _call_connection_lost
    self._protocol.connection_lost(exc)
  File ".homeassistant/homeassistant/lib/python3.11/site-packages/pymodbus/transport/transport.py", line 288, in connection_lost
    self.__close()
TypeError: AsyncModbusTcpClient.close() got an unexpected keyword argument 'intern'
2024-03-21 10:05:10.612 INFO (MainThread) [custom_components.solax_modbus] exception AsyncModbusTcpClient.close() got an unexpected keyword argument 'intern' : InverterZCS cannot read holding registers at device 1 position 0x620
NoneType: None

I reverted to Home Assistant 2023.3.0

andbad commented 3 months ago

Updated to 2023.3.7 Beta 1 and then Home assistant to 2023.3.1 The integration stop to update data after some minutes.

By(t)e

andbad commented 3 months ago

In the Home Assistant 2023.3.1 changelog I noticed that some changes have been made to modbus.

Considering that with the HA version 2023.3.0 (before these changes) I don't encounter the problem while with the 2023.3.1 version I do, is it possible that the cause is the changes introduced to modbus?

By(t)e

wills106 commented 3 months ago

2024.02.6 Introduced the main change of using async for communications.

Introduction of pyModbus v3.6.6 was trying to address #807 HA is updating to pyModbus v3.6.6 as well 2024.3.2

andbad commented 3 months ago

I updated HA to version 2023.3.2 about 1 hour and a half ago and it's still working for now. Thank you

By(t)e

wills106 commented 3 months ago

What version of the Integration are you using with HA 2024.3.2?

andbad commented 3 months ago

2023.3.7 Beta 1

By(t)e

hubertozog commented 3 months ago

Ok, for me for 5 days any issues for last days - all working fine. Critical was correct configuration of waveshare and clean installation of integration. Thanks for your hard work!

wills106 commented 3 months ago

Did you use the settings Zwer2k shared?

hubertozog commented 3 months ago

Yes, the difference was with wait time and iddle time. After that tweaks - i didnt receaived any error. So IMO that was main issue. Maybe it could be good idea to add that information to documentation for Sofar users?

hubertozog commented 3 months ago

Unfortunetl yesterday the integration stops again. With that msg. Gonna update to the newest version and will try again. The biggest issue is that it even didnt try to reconect. Tried remove integration, restart of Waveshare, HA. Nothing helps. Probably if i would connect Inverter to the other adapter it would work again. But it was faster to reboot inverter itself.

2024-03-25 03:32:55.375 INFO (MainThread) [custom_components.solax_modbus] exception Modbus Error: [Input/Output] ERROR: No response received after 3 retries : Sofar cannot read holding registers at device 1 position 0x404

Any other error. Only that information and nothing else in logs :/

wills106 commented 3 months ago

Try 2024.03.8b1 if your still having issues.

ppiwowar commented 3 months ago

I had same issues yesterday after upgrading integration to version ... .7. After I reversed to ... .3 it is all fine for more then 24h.

hubertozog commented 3 months ago

Ok update done, gonna test. Thanks for your hard work!