remco-k / domoticz-goodwe-modbusudp-plugin

A Domoticz plugin that connects to GoodWe inverters over LAN or WLAN via UDP that supports Modbus.
4 stars 1 forks source link

Domoticz Log show lots of errors, yet plugin functions as normal (I think) #4

Open mvanrooijenjr opened 1 year ago

mvanrooijenjr commented 1 year ago

Hiya,

I'm getting the following errors spammed every 5 sec (it's the interval). Yet, the plugin seems to work as normal. My inverter is: GW3600D-NS I am on your latest pull of the master branch (as of today).

2023-03-12 11:53:16.068 Error: GoodWe Omvormer: Call to function 'onHeartbeat' failed, exception details:
2023-03-12 11:53:16.070 Error: GoodWe Omvormer: Traceback (most recent call last):
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/usr/local/lib/python3.7/dist-packages/goodwe/inverter.py", line 108, in _read_from_socket
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: result = await command.execute(self.host, self.timeout, self.retries)
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/usr/local/lib/python3.7/dist-packages/goodwe/protocol.py", line 109, in execute
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: await response_future
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: goodwe.exceptions.MaxRetriesException
2023-03-12 11:53:16.071 Error: GoodWe Omvormer:
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: During handling of the above exception, another exception occurred:
2023-03-12 11:53:16.071 Error: GoodWe Omvormer:
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: Traceback (most recent call last):
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/home/pi/domoticz/plugins/domoticz-goodwe-modbusudp-plugin/plugin.py", line 455, in onHeartbeat
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: _plugin.onHeartbeat()
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/home/pi/domoticz/plugins/domoticz-goodwe-modbusudp-plugin/plugin.py", line 302, in onHeartbeat
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: runtime_data = asyncio.run( self.inverter.read_runtime_data() )
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: return loop.run_until_complete(main)
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: return future.result()
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/usr/local/lib/python3.7/dist-packages/goodwe/dt.py", line 156, in read_runtime_data
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: raw_data = await self._read_from_socket(self._READ_DEVICE_RUNNING_DATA)
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: File "/usr/local/lib/python3.7/dist-packages/goodwe/inverter.py", line 114, in _read_from_socket
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: self._consecutive_failures_count)
2023-03-12 11:53:16.071 Error: GoodWe Omvormer: goodwe.exceptions.RequestFailedException: ('No valid response received even after 3 retries', 3)
remco-k commented 1 year ago

Error No valid response received even after 3 retries is given if the plugin can't connect to the inverter after 3 tries. Seems to me this is caused by a connectivity issue. No data is received while this situation occurs. Please check your (Wifi) network. A good stable network must be present at your inverter side.

mvanrooijenjr commented 1 year ago

The interesting thing is that the plugin functions as normal. Do i have my interval set to frequent? Needs to be higher than 5 seconds?

It also spams it throughout the night when the inverter is off, so looks like the shutdown mode is not working? It keeps trying happily every 5 seconds even though the inverter is off.

mvanrooijenjr commented 1 year ago

Small update. It is working as normal and the error is only showed on the interval (so every 5 seconds) when the inverter is asleep (when the sun is down) so it appears for my specific model the sleep / disconnect / wait more is not supported? Can you elaborate or confirm this might be the case? Is there anything I can do to make it work?

remco-k commented 1 year ago

I have it set to 1 second and working perfecly. So 5 seconds - with a good network connection - should be perfectly fine.

I reviewed your error and my Python code, I see some room for improvements, for example you get the goodwe.exceptions.RequestFailedException exception, which isn't handled and therefore you get the error each interval time.

Currently working on it, if all goes well I'll push a test version later today.

mvanrooijenjr commented 1 year ago

I've set up an acces point in the attic, so connection should be much better now.

Thank for your plugin, love it that you're still making improvements and I look forward to trying the test version.

remco-k commented 1 year ago

I have done some changes today. Fixed the bug.

This should solve the appearance of errors occurring at every interval. It now counts and logs the connection failures, if that number reaches 5 it will disconnect from the inverter and upon the next onHeartbeat interval tries to reconnect. That reconnect contains an existing back-off mechanism which waits 30 seconds after a connection failure occurs. This still logs some errors - which is fine - but it will be way less then it was before and those error messages should be more informative about the state we are in.

I pushed today's changes to a separate branch, so master is unaffected while we are trying to sort this issue out. Please download or clone from this branch: https://github.com/remco-k/domoticz-goodwe-modbusudp-plugin/tree/issue4-errors-on-interval-when-sleep To see all changes: https://github.com/remco-k/domoticz-goodwe-modbusudp-plugin/compare/master...issue4-errors-on-interval-when-sleep

A quick help for you if you did a git clone to your Domoticz system, type these commands:

git pull
git checkout issue4-errors-on-interval-when-sleep

If you want to go back to the master branch:

git checkout master

Remember that you must restart Domoticz after updating a plugin. If things don't work like expected, first validate if you are running the right version of this plugin. Upon startup of Domoticz or the plugin, its version number is logged. This should be found in the Domoticz log like this (The name Goodwe varies, depending on your hardware config in Domoticz):

2023-03-18 12:15:43.532 Status: Goodwe: Initialized version 0.0.5, author 'Remco Kuijer'

I would like to hear from you if things work out for you.

mvanrooijenjr commented 1 year ago

I have pulled, checkout and restarted - confirm: it is now running on that branch on 0.0.5.

I will report when my inverter shuts down for the night. but so far it seems to work like normal.

mvanrooijenjr commented 1 year ago

It seems to work!

2023-03-20 19:03:50.109 Error: GoodWe Omvormer: If this problem persists, please check if your family model (NS) is correct for your inverter and check your network connections.
2023-03-20 19:04:25.087 Error: GoodWe Omvormer: Request failed: Cannot connect to inverter: No valid response received even after 3 retries

These are now the errors, but far less frequent (every 30 seconds) which is alright.

Should I set my inverter family to auto? Or is the error generic?

remco-k commented 1 year ago

Sorry for the late answer. No, you should not set inverter family to auto unless you think something is wrong. This error is generic and is logged whenever the inverter is unreachable, which is the case in night time.