home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.83k stars 28.94k forks source link

Goodwe integration not working with LAN module #114173

Open ivik opened 3 months ago

ivik commented 3 months ago

The problem

I have a GW15K-ET which works fine with HA GoodWe integration when using the Wifi module. But as soon as I change to the LAN/WIFI module then HA is not able to find it anymore.

I remove everything and start new integration, I give it the LAN IP and it says "Unknown error occurred" Same if I give it Wifi IP from the LAN/Wifi module.

But If I remove everything again, change to only Wifi module and give it the IP then it works great.

LAN/Wifi module works as I can see data in SEMS portal.

I found some info in the logs, please see below

What version of Home Assistant Core has the issue?

core-2024.3.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

GoodWe inverter

Link to integration documentation on our website

https://www.home-assistant.io/integrations/goodwe

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

File "/usr/src/homeassistant/homeassistant/components/goodwe/config_flow.py", line 36, in async_step_user
    inverter = await connect(host=host, retries=10)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/goodwe/__init__.py", line 52, in connect
    return await discover(host, timeout, retries)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/goodwe/__init__.py", line 72, in discover
    response = await DISCOVERY_COMMAND.execute(host, timeout, retries)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/goodwe/protocol.py", line 109, in execute
    await response_future
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1228, in _read_ready
    data, addr = self._sock.recvfrom(self.max_size)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionRefusedError: [Errno 111] Connection refused

Additional information

No response

xrsprint commented 1 month ago

Also forgot to ask in the last post is there a way to change an existing dongles IP address and TCP/UDP Mode, just makes it heaps easier when changing dongles over all the time?

Thanks again

RalfWinter commented 1 month ago

Well, the dongles obtain their IP-address via DHCP your router will assign unique IP addresses per MAC. You could switch off DHCP in the dongle's config and assign an IP address manually.

xrsprint commented 1 month ago

Thanks for that yeah that’s what I’m doing at the moment but more thinking about the old unit using UDP and the new one TCP I’m more than anything

ivik commented 1 month ago

@mletenay

Hi

I finially got time to try this out using HACS, I downloaded the master version. It kind of work and does not work :D Same with the inverter_check.py script and the new script you have me which made output of all sensors. They usually work first time I call them. They also work if I call them for example once each minutes. But if I run them each 5s or even 10s they break and wont work again until I restart inverter or wait a long time.

It usually works the first time, sometimes a second time. But it kind of gets stuck after a while and gives errors, example when running the small script you gave me:

(goodwe_test) PS C:\python\goodwe\tests> python.exe .\new_test.py Traceback (most recent call last): File "C:\python\goodwe\tests\new_test.py", line 18, in asyncio.run(get_runtime_data()) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\base_events.py", line 649, in run_until_complete return future.result() File "C:\python\goodwe\tests\new_test.py", line 11, in get_runtime_data inverter = await goodwe.connect('192.168.0.23', 502) File "C:\python\goodwe\tests../../goodwe\goodwe__init__.py", line 56, in connect await inv.read_device_info() File "C:\python\goodwe\tests../../goodwe\goodwe\et.py", line 448, in read_device_info response = await self._read_from_socket(self._READ_DEVICE_VERSION_INFO) File "C:\python\goodwe\tests../../goodwe\goodwe\inverter.py", line 122, in _read_from_socket result = await command.execute(self._protocol) File "C:\python\goodwe\tests../../goodwe\goodwe\protocol.py", line 372, in execute response_future = await protocol.send_request(self) File "C:\python\goodwe\tests../../goodwe\goodwe\protocol.py", line 244, in send_request await self._connect() File "C:\python\goodwe\tests../../goodwe\goodwe\protocol.py", line 194, in _connect self._transport, self.protocol = await asyncio.get_running_loop().create_connection( File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\base_events.py", line 1076, in create_connection raise exceptions[0] File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\base_events.py", line 1060, in create_connection sock = await self._connect_sock( File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\base_events.py", line 969, in _connect_sock await self.sock_connect(sock, address) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\proactor_events.py", line 709, in sock_connect return await self._proactor.connect(sock, address) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\windows_events.py", line 826, in _poll value = callback(transferred, key, ov) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\windows_events.py", line 613, in finish_connect ov.getresult() OSError: [WinError 121] The semaphore timeout period has expired

Same script worked couple of minutes ago. It seems to get stuck when checking values after couple of times.

After a lot of headache I got it to work in HA, I basically had to restart couple of times, both HA and the actual inverter to make sure no calls where made before HA and inverted booted up at the same time, then I got HA to find and get it going.

But all the sensors became unavailable handful of times each minute, all the time. There was no way I could get them stable for more than 20s before they became unavailable and then 5-10s later came back for another 10-20s and then unavailable. Back and forth all the time.

I even tried to change the scan interval to 10s instead of default 5s. Still did not help, it just got unavailable and then back and forth. I did not try to change it to larger, perhaps 30s. But the default Goodwe integration is set on 10s and works fine with the wifi. Even if the LAN would work with 30s it would be bad, I would say 10s is max. Lower would even be better. But 10s is doable/fine.

To sum it up, it works but really unstable.

Some debug from HA before I got it working by making sure no calls where made before I restarted both HA and inverter: I manually wrote ET as family:

2024-05-12 00:15:02.550 DEBUG (MainThread) [goodwe] Connecting to ET family inverter at 192.168.0.23:502. 2024-05-12 00:15:02.550 DEBUG (MainThread) [goodwe.protocol] Creating lock instance for current event loop. 2024-05-12 00:15:02.550 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:07.552 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:07.552 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:12.554 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:12.554 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:17.556 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:17.556 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:22.557 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:22.558 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:27.558 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:27.559 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:32.559 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:32.560 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:37.561 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:37.561 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:42.562 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:42.563 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:47.564 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:47.565 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:52.566 DEBUG (MainThread) [goodwe.protocol] Connection refused error. 2024-05-12 00:15:52.567 DEBUG (MainThread) [goodwe.protocol] Opening connection. 2024-05-12 00:15:57.568 DEBUG (MainThread) [goodwe.protocol] Max number of retries (10) reached, request None failed.

Also debug from scan script when it worked on the first run but starting acting up on the second run:

(goodwe_test) PS C:\python\goodwe\tests> python.exe .\inverter_check.py 2024-05-12 00:17:23,531 init(54) - DEBUG: Using selector: SelectSelector 2024-05-12 00:17:23,531 connect(55) - DEBUG: Connecting to ET family inverter at 192.168.0.23:502. 2024-05-12 00:17:23,531 _ensure_lock(43) - DEBUG: Creating lock instance for current event loop. 2024-05-12 00:17:23,531 _connect(193) - DEBUG: Opening connection. 2024-05-12 00:17:44,572 send_request(262) - DEBUG: Connection refused error: [Errno 10060] Connect call failed ('192.168.0.23', 502) 2024-05-12 00:17:44,572 _connect(193) - DEBUG: Opening connection. 2024-05-12 00:18:05,599 send_request(262) - DEBUG: Connection refused error: [Errno 10060] Connect call failed ('192.168.0.23', 502) 2024-05-12 00:18:05,599 _connect(193) - DEBUG: Opening connection. 2024-05-12 00:18:26,617 send_request(262) - DEBUG: Connection refused error: [Errno 10060] Connect call failed ('192.168.0.23', 502) 2024-05-12 00:18:26,617 _connect(193) - DEBUG: Opening connection. 2024-05-12 00:18:47,635 _max_retries_reached(293) - DEBUG: Max number of retries (3) reached, request None failed. Traceback (most recent call last): File "C:\python\goodwe\tests\inverter_check.py", line 27, in inverter = asyncio.run(goodwe.connect(IP_ADDRESS, PORT, FAMILY, COMM_ADDR, TIMEOUT, RETRIES)) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\base_events.py", line 649, in run_until_complete return future.result() File "C:\python\goodwe\tests../../goodwe\goodwe__init__.py", line 56, in connect await inv.read_device_info() File "C:\python\goodwe\tests../../goodwe\goodwe\et.py", line 448, in read_device_info response = await self._read_from_socket(self._READ_DEVICE_VERSION_INFO) File "C:\python\goodwe\tests../../goodwe\goodwe\inverter.py", line 127, in _read_from_socket raise RequestFailedException(f'No valid response received even after {self._protocol.retries} retries', goodwe.exceptions.RequestFailedException: ('No valid response received even after 3 retries', 1)

ivik commented 1 month ago

For anybody going from the regular Goodwe integration to HACS and going from wifi module to the new LAN v2 module:

Uou need to remove the device before attempting to add new one. Or else it will not really understand and try old ip (wifi instead of lan) and using UDP port instead of TCP even if you give new IP and choose TCP.

mletenay commented 1 month ago

Thanks for the feedback, I'm going to analyze it. I will also adjust the config dialog so it will be easier to change IP and protocol via UI.

Anyway, this github ticket is fine place to collect feedback and discussion, but sometime it might be more efficient to talk directly. So just reminder for those who do not know - we have a discord channel and I've just created dedicated TCP related sub-channel here - https://discord.com/channels/758315145922740234/1239152054040268850

mletenay commented 1 month ago

@xrsprint @ivik Something quite odd is happening there. At this point I do not know whose bug it is, but what seems to happen is that the inverter replies with some garbage after proper payload. First request is fine, second has 512 bytes of additional garbage, 2nd 1024 bytes of garbage etc. (The garbage contains e.g. IP address of HA as ascii string and "modbus_tcp" string as well ???). It smell a lot like some buffer overflow on goodwe side, but it's just a guess at this moment. I have 2 potential fixes/workarounds in mind (use proper modbus tx counters and option to close connection after every request). Hoping to implement them tomorrow ...

ivik commented 1 month ago

@mletenay

I have not seen output like the one @xrsprint have displayed. Not sure if we have the same issue or we are talking about 2 different issues. We have different inverters so there could be different issues/bugs we are talking about.

But let me know when you have new code and I will try it out. If possible, create a script that does sensor reads each 10s or whatever and I will have it go for couple of minutes and see what happens. Perhaps you could put the update time in a variable which I could play around with if needed.

xrsprint commented 1 month ago

and if anyone wants me to run any scrips, more than happy to, might need a couple of pointers on how to run it 📦

mletenay commented 1 month ago

@xrsprint @ivik I have made some adjustments to the code.

If you checkout the latest sources from the https://github.com/marcelblijleven/goodwe, you can find new python script stability_check.py in the tests folder. It should connect to the TCP server and send request every 5 seconds in a loop. You should obviously adjust the IP and you can fiddle with params - e.g. the timeout and the keep_alive (commented out by default).

xrsprint commented 1 month ago

Thanks for that @mletenay i will give this a go this afternoon and report back. Im still not sure how to run scripts but will update the source and let you know

Thanks again for the great work and will revert back !

ivik commented 1 month ago

@mletenay I tried the discord link but it does not work. Please send invite to: erfan8882

I downloaded the new code. I ran it and it worked but had strange output: Same request output over and over again, I have attached the first 2:

C:\python\goodwe\tests> python.exe .\stability_check.py 2024-05-14 23:15:55,566 init(54) - DEBUG: Using selector: SelectSelector 2024-05-14 23:15:55,566 connect(55) - DEBUG: Connecting to None family inverter at 192.168.0.23:502. 2024-05-14 23:15:55,566 _ensure_lock(56) - DEBUG: Creating lock instance for current event loop. 2024-05-14 23:15:55,566 _connect(213) - DEBUG: Opening connection. 2024-05-14 23:15:55,582 connection_made(229) - DEBUG: Connection opened. 2024-05-14 23:15:55,582 _send_request(311) - DEBUG: Sending: READ 33 registers from 35000 (000100000006f70388b80021) 2024-05-14 23:15:55,613 data_received(250) - DEBUG: Received: 000100000045f7034200003a980001393031354b455454323334573036373200000000000000000000000700071b9c0008019130343036322d30372d53303030323032302d30382d533031 2024-05-14 23:15:55,613 _send_request(311) - DEBUG: Sending: READ 6 registers from 47547 (000200000006f703b9bb0006) 2024-05-14 23:15:55,629 data_received(250) - DEBUG: Received: 00020000000ff7030c000000000000000000000000 2024-05-14 23:15:55,629 _send_request(311) - DEBUG: Sending: READ 6 registers from 47589 (000300000006f703b9e50006) 2024-05-14 23:15:55,660 data_received(250) - DEBUG: Received: 00030000000ff7030cffff00000000000000000000 2024-05-14 23:15:55,660 connect(57) - DEBUG: Connected to inverter , S/N:9015KETT234W0672. 2024-05-14 23:15:55,660 get_runtime_data(38) - INFO: ################################ 2024-05-14 23:15:55,660 get_runtime_data(39) - INFO: Request 1 2024-05-14 23:15:55,660 get_runtime_data(40) - INFO: ################################ 2024-05-14 23:15:55,660 _send_request(311) - DEBUG: Sending: READ 125 registers from 35100 (000400000006f703891c007d) 2024-05-14 23:15:55,707 data_received(250) - DEBUG: Received: 0004000000fdf703fa18050e170f36000000000000000000000000000000000000000000000000000000000000000000000000091e0002138400000000092500001386ffffffff091b00001384ffffffff0001fffffffefffffc450000002e0000002e000f00000a31000000000000000f00001386000000000000000f0000001e0000000000000000028c0000001c0000011100000000000003be0000014a0069010d0000134d09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d47a01ee0000020b00000000012e000000080000000000000000021100000000020401c8000000000000 2024-05-14 23:15:55,707 _send_request(311) - DEBUG: Sending: READ 58 registers from 36000 (000500000006f7038ca0003a) 2024-05-14 23:15:55,738 data_received(250) - DEBUG: Received: 000500000177f703740007003b000a00000001fd74ffe3feeefc4501acffa1ffebffadffad13850000000000000000fffffd74ffffffe3fffffeeefffffc45000000910000008100000099000001acfffffd52ffffff7dfffffeb5fffffb83000200050000000000000000000000000000091909220917001d0005000e9103001e0000000000000000028c0000001c0000011100000000000003be0000014a0069010d0000134d09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d47a01ee0000020b00000000012e000000080000000000000000021100000000020401c8000000000000976200000500000006f7038ca0003afbfd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2024-05-14 23:15:55,738 _send_request(311) - DEBUG: Sending: READ 61 registers from 35301 (000600000006f70389e5003d) 2024-05-14 23:15:55,785 data_received(250) - DEBUG: Received: 00060000017df7037a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000409300930093000000000ffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000787b00000000028c0000001c0000011100000000000003be0000014a0069010d0000134d09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d47a01ee0000020b00000000012e000000080000000000000000021100000000020401c8000000000000976200000600000006f70389e5003dab26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2024-05-14 23:16:00,785 get_runtime_data(38) - INFO: ################################ 2024-05-14 23:16:00,785 get_runtime_data(39) - INFO: Request 2 2024-05-14 23:16:00,785 get_runtime_data(40) - INFO: ################################ 2024-05-14 23:16:00,785 _send_request(311) - DEBUG: Sending: READ 125 registers from 35100 (000700000006f703891c007d) 2024-05-14 23:16:00,817 data_received(250) - DEBUG: Received: 0007000001fdf703fa18050e170f3b000000000000000000000000000000000000000000000000000000000000000000000000091c000113840000000009240000138300000000091c0000138500000000000100000000fffffc170000001600000017001000000a31000000000000001000001386000000000000000f0000001e000000000000000002960000001c0000013600000000000003dc0000014a0069010d0000134d09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d47a01ee0000020b00000000012e000000080000000000000000021100000000020401c8000000000000835d00000700000006f703891c007d7ae70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2024-05-14 23:16:00,817 _send_request(311) - DEBUG: Sending: READ 58 registers from 36000 (000800000006f7038ca0003a) 2024-05-14 23:16:00,848 data_received(250) - DEBUG: Received: 000800000277f703740007003b000a00000001fd6affe4fecafc1701b1ffa1ffebffabffad13840000000000000000fffffd6affffffe4fffffecafffffc1700000095000000810000009a000001b1fffffd48ffffff7dfffffe95fffffb59000200050000000000000000000000000000091809220915001e0005000fe039001e000000000000000002960000001c0000013600000000000003dc0000014a0069010d0000134d09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d47a01ee0000020b00000000012e000000080000000000000000021100000000020401c8000000000000835d00000800000006f7038ca0003afbfd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003139322e3136382e302e33000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2024-05-14 23:16:00,848 _send_request(311) - DEBUG: Sending: READ 61 registers from 35301 (000900000006f70389e5003d) 2024-05-14 23:16:00,895 data_received(250) - DEBUG: Received: 00090000027df7037a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000409300930093000000000ffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000787b0000000002960000001c0000013600000000000003dc0000014a0069010d0000134d09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d47a01ee0000020b00000000012e000000080000000000000000021100000000020401c8000000000000835d00000900000006f70389e5003dab2600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003139322e3136382e302e33000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

But then I changed your script a bit and added output for actual sensor values, I made this change:

` async def get_runtime_data(): inverter = await goodwe.connect(host='192.168.0.23', port=502, family='ET', timeout=1, retries=3)

inverter.keep_alive = False

i = 1
while True:
    logger.info("################################")
    logger.info("          Request %d", i)
    logger.info("################################")
    #await inverter.read_runtime_data()
    runtime_data = await inverter.read_runtime_data()
    for sensor in inverter.sensors():
        if sensor.id_ in runtime_data:
            print(f"{sensor.id_}: \t\t {sensor.name} = {runtime_data[sensor.id_]} {sensor.unit}")        
    await asyncio.sleep(5)
    i += 1

`

That made it more interesting, it was able to do the output of all sensors for 7 runs but it then crasched:

2024-05-14 23:22:18,699 get_runtime_data(38) - INFO: ################################ 2024-05-14 23:22:18,699 get_runtime_data(39) - INFO: Request 7 2024-05-14 23:22:18,699 get_runtime_data(40) - INFO: ################################ 2024-05-14 23:22:18,699 _send_request(311) - DEBUG: Sending: READ 125 registers from 35100 (001600000006f703891c007d) 2024-05-14 23:22:18,731 data_received(250) - DEBUG: Received: 0016000005fdf703fa18050e171611000000000000000000000000000000000000000000000000000000000000000000000000090b0002138800000000091200001389ffffffff091200001384000000000001ffffffffffffefd00000002d0000002e000f00000a31000000000000001000001386000000000000000f0000001e0000000000000000078500000438000004720000000000001031000001470069010a0000134e09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d47c01f00000020b00000000012e000000080000000000000000021100000000020401c8000000000000716b00001600000006f703891c007d7ae700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003139322e3136382e302e330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001002c36ec0a800030000000000000000000000000000000000000000000201f60000000000000000000000000000000000000000000000000306000010000000010000007ae7000000000000000000000000000080b3fd3f0c000000000000000000000000000000f0b2fd3f39000000fcb1fd3f0000000000000000000000000000000000000000000000000cb4fd3f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a5a5a5a5a5a5a5a5a5a5a5a5a5a5a57001000090aefd3f00b4fd3f450f0700a03cfc3fa03cfc3f74b4fd3f983cfc3f14000000fcc7fd3ffcc7fd3f74b4fd3f0000000005000000709cfd3f6d6f646275735f74637000b07300272c31ef721dcc226b886cfa6c50a0fbc300ffffff7f60b4fd3f0e0000000000000005000000000000008813ff3f8c440d4080000000c067fb3f2868fb3f9068fb3f000000000000000001000000000000000000000000000000481d004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003f5c00000000000000e8b5fd3f00000000000000000000000000b6fd3fffffffff00b6fd3f00b6fd3f0000000014b6fd3fffffffff14b6fd3f14b6fd3f010000000100000000000000ffff000200000000b8e41b68018e174bffff3fb30000000014000000e48afc3f589cfd3ff70026067033413f60b6fd3f5c0000000000000060b6fd3f00000000000000000000000078b6fd3fffffffff78b6fd3f78b6fd3f000000008cb6fd3fffffffff 2024-05-14 23:22:18,731 _send_request(311) - DEBUG: Sending: READ 58 registers from 36000 (001700000006f7038ca0003a) 2024-05-14 23:22:18,731 validate_modbus_tcp_response(248) - DEBUG: Response is command failure: ILLEGAL FUNCTION. 2024-05-14 23:22:18,731 data_received(260) - DEBUG: Received exception response: 8cb6fd3f8cb6fd3f010000000100000000000000ffff008b00000000fa5acfd301f2ecfbffff3fb300000000040600000000000024b7fd3f63006300800001000000000000000000f1f7c0a80003c0a800176ec3f601b0c7bfeabcdf2ee0501020fdf9 Traceback (most recent call last): File "C:\python\goodwe\tests\stability_check.py", line 50, in asyncio.run(get_runtime_data()) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\base_events.py", line 649, in run_until_complete return future.result() File "C:\python\goodwe\tests\stability_check.py", line 42, in get_runtime_data runtime_data = await inverter.read_runtime_data() File "C:\python\goodwe\tests..\goodwe\et.py", line 591, in read_runtime_data raise ex File "C:\python\goodwe\tests..\goodwe\et.py", line 580, in read_runtime_data response = await self._read_from_socket(self._READ_METER_DATA_EXTENDED) File "C:\python\goodwe\tests..\goodwe\inverter.py", line 123, in _read_from_socket result = await command.execute(self._protocol) File "C:\python\goodwe\tests..\goodwe\protocol.py", line 409, in execute response_future = await protocol.send_request(self) File "C:\python\goodwe\tests..\goodwe\protocol.py", line 277, in send_request await response_future File "C:\python\goodwe\tests..\goodwe\protocol.py", line 249, in data_received if self.command.validator(data): File "C:\python\goodwe\tests..\goodwe\protocol.py", line 602, in lambda x: validate_modbus_tcp_response(x, cmd, offset, value), File "C:\python\goodwe\tests..\goodwe\modbus.py", line 249, in validate_modbus_tcp_response raise RequestRejectedException(failure_code) goodwe.exceptions.RequestRejectedException: ILLEGAL FUNCTION

I also tried to change the sleep time to 10s and tried again, it had the same crash as above after run number 6.

2024-05-14 23:32:40,963 get_runtime_data(38) - INFO: ################################ 2024-05-14 23:32:40,963 get_runtime_data(39) - INFO: Request 6 2024-05-14 23:32:40,963 get_runtime_data(40) - INFO: ################################ 2024-05-14 23:32:40,964 _send_request(311) - DEBUG: Sending: READ 125 registers from 35100 (001300000006f703891c007d) 2024-05-14 23:32:41,022 data_received(250) - DEBUG: Received: 0013000005fdf703fa18050e172028000000000000000000000000000000000000000000000000000000000000000000000000091300011384ffffffff09150000138900000000091b0000138a000000000001ffffffffffffef7f0000001700000017000f00000a31000000000000001000001386000000000000000f0000001e0000000000000000073f0000049b000004a5000000000000108400000143006901050000134e09b50000000000000000000000040029000000000000000000006d1b000003db00006d1a000006a203da0000022700000001d48401f80000020b00000000012e000000080000000000000000021100000000020401c80000000000007d1100001300000006f703891c007d7ae700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003139322e3136382e302e330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001002c4ccc0a800030000000000000000000000000000000000000000000201f60000000000000000000000000000000000000000000000000306000010000000010000007ae7000000000000000000000000000080b3fd3f0c000000000000000000000000000000f0b2fd3f39000000fcb1fd3f0000000000000000000000000000000000000000000000000cb4fd3f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a5a5a5a5a5a5a5a5a5a5a5a5a5a5a57001000090aefd3f00b4fd3f088e1000a03cfc3fa03cfc3f74b4fd3f983cfc3f14000000fcc7fd3ffcc7fd3f74b4fd3f0000000005000000709cfd3f6d6f646275735f74637000b07300272c31ef721dcc226b886cfa6c50a0fbc300ffffff7f60b4fd3f0e0000000000000005000000000000008813ff3f8c440d4080000000c067fb3f2868fb3f9068fb3f000000000000000001000000000000000000000000000000481d004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003f5c00000000000000e8b5fd3f00000000000000000000000000b6fd3fffffffff00b6fd3f00b6fd3f0000000014b6fd3fffffffff14b6fd3f14b6fd3f010000000100000000000000ffff000200000000b8e41b68018e174bffff3fb30000000014000000e48afc3f589cfd3ff70026067033413f60b6fd3f5c0000000000000060b6fd3f00000000000000000000000078b6fd3fffffffff78b6fd3f78b6fd3f000000008cb6fd3fffffffff 2024-05-14 23:32:41,023 _send_request(311) - DEBUG: Sending: READ 58 registers from 36000 (001400000006f7038ca0003a) 2024-05-14 23:32:41,024 validate_modbus_tcp_response(248) - DEBUG: Response is command failure: ILLEGAL FUNCTION. 2024-05-14 23:32:41,024 data_received(260) - DEBUG: Received exception response: 8cb6fd3f8cb6fd3f010000000100000000000000ffff008b00000000fa5acfd301f2ecfbffff3fb300000000040600000000000024b7fd3f63006300800001000000000000000000f1d6c0a80003c0a80017ccc4f601b1c905332f36c48050109df7bc Traceback (most recent call last): File "C:\python\goodwe\tests\stability_check.py", line 50, in asyncio.run(get_runtime_data()) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Erfan\anaconda3\envs\goodwe_test\lib\asyncio\base_events.py", line 649, in run_until_complete return future.result() File "C:\python\goodwe\tests\stability_check.py", line 42, in get_runtime_data runtime_data = await inverter.read_runtime_data() File "C:\python\goodwe\tests..\goodwe\et.py", line 591, in read_runtime_data raise ex File "C:\python\goodwe\tests..\goodwe\et.py", line 580, in read_runtime_data response = await self._read_from_socket(self._READ_METER_DATA_EXTENDED) File "C:\python\goodwe\tests..\goodwe\inverter.py", line 123, in _read_from_socket result = await command.execute(self._protocol) File "C:\python\goodwe\tests..\goodwe\protocol.py", line 409, in execute response_future = await protocol.send_request(self) File "C:\python\goodwe\tests..\goodwe\protocol.py", line 277, in send_request await response_future File "C:\python\goodwe\tests..\goodwe\protocol.py", line 249, in data_received if self.command.validator(data): File "C:\python\goodwe\tests..\goodwe\protocol.py", line 602, in lambda x: validate_modbus_tcp_response(x, cmd, offset, value), File "C:\python\goodwe\tests..\goodwe\modbus.py", line 249, in validate_modbus_tcp_response raise RequestRejectedException(failure_code) goodwe.exceptions.RequestRejectedException: ILLEGAL FUNCTION

xrsprint commented 1 month ago

Hi Everyone

i tried and tired, but still couldnt figure out how to run the scripts, but i uninstalled and re-installed the app to the new Lan module and was getting the same thing

only thing I also noticed is in the integration logbook, every five seconds the timestamp is updated, an on each fouth update is when we loose the entities, then on the next update they come back

hope this helps in some way :)

mletenay commented 1 month ago

@ivik The output confirms previous observation - there is more and more garbage at the end of response until it crashes. Can you try now while un-commenting the '# inverter.keep_alive = False' ?

Use this invite link - https://discord.gg/TaXyWXT

mletenay commented 1 month ago

@ivik I have added standard pymodbus library version to stability_check.py to find out whether my code is wrong or not. Checkout the latest sources, install pymodbus (pip install pymodbus) and comment the get_runtime_data and uncomment the pymodbus above instead.

mletenay commented 1 month ago

Just FYI - I've collected data both via my code and standard pymodbus. Will analyze it further, but so far it really seems Goodwe has bug in Modbus/TCP implementation (kind of buffer overflow?). They add illegal gargabe at the end of subsequent responses until something internally overflows and their interface crashes ! Modbus specification explicitly recommends the TCP connection should be kept open for subsequent requests, but they are not able to handle it. If the TCP connection is closed after every single request, the inverter seems to work fine and responds properly !

mletenay commented 1 month ago

Just FYI - see the announcement on discord - the v0.9.9.20 is out there and should be production ready with the "keep alive" flag turned off.

ivik commented 1 month ago

Hi, sorry for late reply, been busy lately. I finally downloaded the latest version, first it did not want to work. I had to delete the inverter from HA and then restart and then it start working.

I have 5s polling and it has been working great the last 5min. If no issues for couple of days I will close this ticket!

ha-reporting2023 commented 1 month ago

You need to select LAN as the "Internet access port" within SEMS Portal WiFi-configuration (I know, "WIFI-configuration" is a bit misleading...). You may want to watch the Goodwe Configuration video of the Wii-Fi+LAN-kit on youtube Good luck!

If you only configure the LAN part then your Goodwe will continue to broadcast the internal WIFI ssid, and worse, it starts to function as an access point. Connecting to the internal WIFI will get you access to the wired LAN segment and even the internet.

mletenay commented 1 month ago

@ivik Do not close it yet, the code is still in HACS only and has to mature a bit to port it to core HA.

ivik commented 1 month ago

Just wanted to report in, it still works great!

RalfWinter commented 1 month ago

Great! Thanks.

ivik commented 1 month ago

Still going strong, no issues at all! Close this ticket whenever you feel it's time to close it but for me it all works great! Thx for all the help!

ivik commented 1 week ago

I will create a new ticket directly under the goodwe integration page but something has happened the last couple of 3-4 days. It looses connection couple of times each minute. I have also tried using different version of the goodwe code, still same issue, all the way back to 0.9.9.25.

I will add more info under a new created ticket: https://github.com/mletenay/home-assistant-goodwe-inverter/issues/292

RalfWinter commented 1 week ago

I received the version 2.0 of the Wifi/LAN Kit, installed it Tuesday and works perfect with the modbus setting. The only thing I recognized: regardless of polling interval below 20 seconds: it will not poll shorter than 20 seconds, bug or feature?

@ivik : did you check for changes in your environment? New firmware versions?

ivik commented 1 week ago

For me it works with 5s interval. I changed to 10s to see if it behaves better after the issue, did not make a difference. Not sure about new firmware updates.

I received a new Goodwe unit (same model as before) and updated it to the newest version of everything. Could have been some new firmware that was updated but pretty sure it was the same as old the old unit (arm v8).

ivik commented 1 week ago

I checked the firmware, the arm seems to be newer version that came out 29 may.

Screenshot_20240628_214937_SolarGo

RalfWinter commented 1 week ago

I would ask Goodwe support for an update. I received updates this week for my ET15, here is what I have: Screenshot_20240630_215054_SolarGo

But be aware that "three phased balanced output" must be off with my versions, if on the WR stops to charge battery and push energy to grid intermittently.

BTW, your communication module version seems quite old in case you have the LAN/Wifi 2.0 installed.

ivik commented 1 week ago

How do i get the coms module updated, when i use the solargo app no new updates are displayed.

RalfWinter commented 1 week ago

I received my updates due to an open ticket (my ET 15 pushed >100 watts into grid when on battery).

You could register there and open a ticket to get the latest updates pushed: https://goodwetechnology.zendesk.com/hc/en-gb