binsentsu / home-assistant-solaredge-modbus

Home assistant Component for reading data locally from Solaredge inverter through modbus TCP
279 stars 70 forks source link

Connection Refused - Leads to Unresponsive Home Assistant #235

Open sockmonkey0223 opened 3 months ago

sockmonkey0223 commented 3 months ago

I've replaced my inverter in the past. After making sure all settings were the same, the integration continued to work fine.

I replaced my inverter again yesterday (yay SolarEdge!). All modbus settings are the same and IP address the same. The inverter is connected via Ethernet. The integration worked for a while but then started reporting "connection refused". I've verified the inverter is still reachable.

More interesting is that if I allow this to continue, it causes HA to become unresponsive and I need to perform a "core restart". I have to disable the integration to prevent this.

Logs: 2024-05-23 13:43:09.410 DEBUG (MainThread) [custom_components.solaredge_modbus] Setup solaredge_modbus.solaredge 2024-05-23 13:43:39.415 INFO (SyncWorker_55) [custom_components.solaredge_modbus] modbus client is not connected, trying to reconnect 2024-05-23 13:43:39.416 INFO (SyncWorker_55) [custom_components.solaredge_modbus] successfully connected to 192.168.69.220:1502 2024-05-23 13:44:08.447 DEBUG (SyncWorker_55) [custom_components.solaredge_modbus] Could not read Active Power Limit 2024-05-23 13:45:35.575 DEBUG (SyncWorker_14) [custom_components.solaredge_modbus] Could not read Active Power Limit 2024-05-23 13:46:33.758 DEBUG (SyncWorker_51) [custom_components.solaredge_modbus] Could not read Active Power Limit 2024-05-23 13:47:02.783 DEBUG (SyncWorker_2) [custom_components.solaredge_modbus] Could not read Active Power Limit 2024-05-23 13:47:03.856 ERROR (SyncWorker_13) [pymodbus.logging] Connection to (192.168.69.220, 1502) failed: [Errno 111] Connection refused 2024-05-23 13:47:03.856 ERROR (SyncWorker_13) [custom_components.solaredge_modbus] Error reading modbus data Traceback (most recent call last): File "/config/custom_components/solaredge_modbus/init.py", line 247, in _refresh_modbus_data update_result = self.read_modbus_data() ^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/solaredge_modbus/init.py", line 322, in read_modbus_data and self.read_modbus_power_limit() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/solaredge_modbus/init.py", line 737, in read_modbus_power_limit inverter_data = self.read_holding_registers( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/solaredge_modbus/init.py", line 305, in read_holding_registers return self._client.read_holding_registers( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pymodbus/client/mixin.py", line 102, in read_holding_registers return self.execute( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pymodbus/client/base.py", line 176, in execute raise ConnectionException(f"Failed to connect[{self!s}]") pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[ModbusTcpClient(192.168.69.220:1502)]

praveenvsn commented 1 month ago

I have the same issue. I just have a single meter with no battery. The Solaredge_m1_imported_kwh and Solaredge_m1_exported_kwh are always -0.0 even though the energy is exported to florid and imported from grid.

sockmonkey0223 commented 1 month ago

I finally started digging into this issue again and discovered that in my Inverter configuration, I had the RS485 setting as "Solar Edge Follower" instead of "SolarEdge Leader". When I corrected that, the integration was once again able to communicate with the inverter.

The documentation from https://github.com/WillCodeForCats/solaredge-modbus-multi/wiki/Configuration helped me figure this out.

I still consider it a problem that the integration causes HA to crash if it cannot communicate.

Edit: changing this setting did not solve the connectivity problem.

gerco commented 2 weeks ago

I have the same issue here, my inverter is connected over somewhat shoddy WiFi. This leads to frequent communication failures and makes my home assistant unusable with this integration enabled since it becomes unresponsive to the point of having to power-cycle it to get it back online about every 20-30 minutes.

gerco commented 2 weeks ago

I worked around the issue using a different integration for now. I tried to debug this one, but had trouble setting up a development environment for it so I didn't pursue that any further. In case anyone else wants to replicate my results, here is a modbus config gist.

This needs to be combined with a set of helpers that convert these values to proper sensors with units of measure, device_class, state_class and scale factor taken into account, etc. It's not a super-easy thing to do and using this integration would be heaps easier and recommended over this hack.