mkaiser / Sungrow-SHx-Inverter-Modbus-Home-Assistant

Sungrow SH Integration for Home Assistant for SH3K6, SH4K6, SH5K-20, SH5K-V13, SH3K6-30, SH4K6-30, SH5K-30, SH3.RS, SH3.6RS, SH4.0RS, SH5.0RS, SH6.0RS, SH5.0RT, SH6.0RT, SH8.0RT, SH10RT, SH5.0RT-20, SH6.0RT-20, SH8.0RT-20, SH10RT-20, SH5.0RT-V112, SH6.0RT-V112, SH8.0RT-V112, SH10RT-V112, SH5.0RT-V122, SH6.0RT-V122, SH8.0RT-V122, SH10RT-V122, SH4.6R
304 stars 79 forks source link

NO VALUE after Home Assistant >= 2024.04 #274

Closed GolfOWL closed 2 months ago

GolfOWL commented 3 months ago

Before you create an issue, make sure to update to the current version of modbus_sungrow.yaml

Describe the bug:

After installing the new version of HA 2024.04 (yesterday) I miss the following values of the variables in the dashboard:

BATTERY sensor.battery_charge sensor.battery_charge_nominal sensor.daily_battery_charge sensor.daily_battery_discharge

sensor.battery_capacity sensor.battery_state_of_health sensor.daily_battery_charge_from_pv sensor.daily_battery_charge sensor.daily_battery_discharge sensor.total_battery_charge_from_pv sensor.total_battery_discharge sensor.total_battery_charge

ENERGY sensor.daily_pv_generation sensor.daily_consumed_energy sensor.daily_imported_energy sensor.daily_exported_energy sensor.total_consumed_energy

sensor.daily_pv_generation sensor.daily_direct_energy_consumption sensor.daily_exported_energy_from_pv sensor.daily_battery_charge_from_pv sensor.daily_battery_discharge sensor.daily_exported_energy sensor.daily_battery_charge sensor.daily_imported_energy sensor.total_pv_generation sensor.total_direct_energy_consumption sensor.total_exported_energy_from_pv sensor.total_battery_charge_from_pv sensor.total_battery_charge sensor.total_battery_discharge sensor.total_imported_energy sensor.total_exported_energy

Your Sungrow inverter:

Home Assistant version:

modbus_sungrow.yaml:

Inverter Firmware Status:

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior I would like to return to the previous state - the display of the values. :-)

Screenshots If applicable, add screenshots to help explain your problem. Screenshot 2024-04-05 094235

Screenshot 2024-04-05 094330

Additional context Thanks in advance

umrath commented 3 months ago

Related to/duplicate of https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant/issues/273

GolfOWL commented 3 months ago

Changed back to HA Core 2024.3.x - and it is running without problems...

umrath commented 3 months ago

Interesting change here! After hopelessly trying to fiddle with everything I could possibly try, I noticed, that the modbus connection gets immediately closed when connecting via telnet to port 502. This was unexpected.

A simple restart of my router (where the Sungrow is connected to) and a restart of the modbus-integration seem to have fixed it. At least for now.

Throntorus commented 2 months ago

Interesting change here! After hopelessly trying to fiddle with everything I could possibly try, I noticed, that the modbus connection gets immediately closed when connecting via telnet to port 502. This was unexpected.

A simple restart of my router (where the Sungrow is connected to) and a restart of the modbus-integration seem to have fixed it. At least for now.

Tried the same, unfortunatelly it can't help. Connection is still broken.

sahnebar commented 2 months ago

I experienced a similar issue with the new version 2024.4. I was able to resolve the problem by reverting to version 2024.3.x, which worked well again. I'm not sure what caused the issue in the newer version, but I'll wait and see if a fix becomes available.

tiko2302 commented 2 months ago

After an update to 2024.4.1 it works for me again.

mkaiser commented 2 months ago

This is really odd..

I went through the HA changelog and the pymodbus changelogs and could not find any commits mentioning some relevant modbus changes (from 24.3 to 24.4.1)

For me it is still working using a modbus proxy (which is also based on pymodbus, so basically the same code base).

Did I miss any changes? I have no clue why it broke for many guys here

Throntorus commented 2 months ago

After an update to 2024.4.1 it works for me again.

I'm on 2024.4.1 (via docker on a Synology NAS) but still not working.

githublakeware commented 2 months ago

Same no value problem for me after Update to HA 2024.4.1 yesteday.

Home Assistant Core 2024.4.1 Supervisor 2024.03.1 Operating System 12.1 Frontend 20240404.1

modbus_sungrow.yaml: 2024-04-05

No idea how everything is implemented. Is there a Python incompatibility for modbus implementation after the last HA update?

Python 3.11 support has previously been deprecated and has now been removed.

https://github.com/home-assistant/core/pull/114220

Modbus has problems: https://github.com/home-assistant/core/issues/115039

TCzerny commented 2 months ago

The only thing I saw on 2024.4 regarding mid is was this: https://github.com/home-assistant/core/pull/113516

Johnnyd1965 commented 2 months ago

I'm having the same problem. some values appear and then disappear..

githublakeware commented 2 months ago

Is that the problem? https://github.com/home-assistant/core/issues/115114#issuecomment-2042112753

mkaiser commented 2 months ago

Good catch! Thank you for the reference....

As it is most likely a HA internal issue, I guess we just need to wait.

I will consolidate all duplicate issues and discussions, soon and write some hints in the readme.md

githublakeware commented 2 months ago

Good catch! Thank you for the reference....

As it is most likely a HA internal issue, I guess we just need to wait.

I will consolidate all duplicate issues and discussions, soon and write some hints in the readme.md

The problem is on the problem tracker list now: https://github.com/home-assistant/core/issues/115236

githublakeware commented 2 months ago

A fix was added to 2024.4.3 HA core milestone now.

GolfOWL commented 2 months ago

A fix was added to 2024.4.3 HA core milestone now.

Cool - good news. Many thanks...

reesaroo74 commented 2 months ago

I was still having troubles with 2024.4.3 with one of my units, so also reverted to 2024.3.3 - working perfectly again

Terminal: "has core update --version 2023.3.3"

githublakeware commented 2 months ago

Home Assistant Core Update 2024.4.3 has been released. I installed it and it solved my problems unfortunately not yet. Even a complete reboot of the system did not help.

Or am I too impatient and still have to wait for the hour?

This is for your information only, as this must be reported to home-assistant/core.

I have errors like: Logger: homeassistant Quelle: /usr/src/homeassistant/homeassistant/runner.py:146 Error doing job: Fatal error: protocol.data_received() call failed.

and

Logger: pymodbus.logging Quelle: runner.py:189 General exception: index out of range

Throntorus commented 2 months ago

Home Assistant Core Update 2024.4.3 has been released. I installed it and it solved my problems unfortunately not yet. Even a complete reboot of the system did not help.

Or am I too impatient and still have to wait for the hour?

This is for your information only, as this must be reported to home-assistant/core.

I have errors like: Logger: homeassistant Quelle: /usr/src/homeassistant/homeassistant/runner.py:146 Error doing job: Fatal error: protocol.data_received() call failed.

and

Logger: pymodbus.logging Quelle: runner.py:189 General exception: index out of range

I can confirm this in exactly the same way. Unfortunately, no improvement after the update.

InFlames82 commented 2 months ago

Home Assistant Core Update 2024.4.3 has been released. I installed it and it solved my problems unfortunately not yet. Even a complete reboot of the system did not help. Or am I too impatient and still have to wait for the hour? This is for your information only, as this must be reported to home-assistant/core. I have errors like: Logger: homeassistant Quelle: /usr/src/homeassistant/homeassistant/runner.py:146 Error doing job: Fatal error: protocol.data_received() call failed. and Logger: pymodbus.logging Quelle: runner.py:189 General exception: index out of range

I can confirm this in exactly the same way. Unfortunately, no improvement after the update.

Same here

mr-p666 commented 2 months ago

And in case the number of reports plays a role... unfortunately it doesn't work for me either!

githublakeware commented 2 months ago

Just opened: https://github.com/home-assistant/core/issues/115489

Andrenato commented 2 months ago

Ich habe das Problem bei mir jetzt gelöst ich habe in der secret.yaml die ip Adresse vom Modbus proxy eingetragen seit dem habe ich keine Probleme mehr

Also die IP von Homeassistent

Throntorus commented 2 months ago

Ich habe das Problem bei mir jetzt gelöst ich habe in der secret.yaml die ip Adresse vom Modbus proxy eingetragen seit dem habe ich keine Probleme mehr

Also die IP von Homeassistent

Can you post how exactly you specified it?

Andrenato commented 2 months ago

Ich habe als addon mostbus Proxy dort ist die ip vom Sungrow Wechselrichter eingetragen unter Konfiguration

anschließend habe ich in der secret yaml die ip Adresse von homeassistent eingetragen Beispiel

der Sungrow Wchselrichter hat 192.168.0.75 Die Ip unter Modus Proxy bei Konfiguration eintragen

anschließend die ip Adresse in der secret.yaml von 192.168.0.75

auf die IP von homeassistent ändern

homeassistent Neustarten und dann sollte es funktionieren

githublakeware commented 2 months ago

I have now also switched to Modbus Proxy (https://github.com/Akulatraxas/ha-modbusproxy) in my environment, but it has not brought any improvement for me. But doesn't that also make sense? The proxy must also be based on the Modbus protocol. And if it is true that Sungrow is not comply witch the protocol (see https://github.com/home-assistant/core/issues/115489#issuecomment-2053728893), then the proxy must also fail. Right?

Andrenato commented 2 months ago

Hast du die IP auch in der Secret yaml auf die IP von Homeassistent geändert?

Gnarfoz commented 2 months ago

I have now also switched to Modbus Proxy (https://github.com/Akulatraxas/ha-modbusproxy) in my environment, but it has not brought any improvement for me. But doesn't that also make sense? The proxy must also be based on the Modbus protocol. And if it is true that Sungrow is not comply witch the protocol (see home-assistant/core#115489 (comment)), then the proxy must also fail. Right?

People use modbus proxies for a different reason: some modbus implementations, like for example Sungrow's, react very badly to receiving multiple requests at the same time. On Sungrow SHxRT devices, it sometimes causes it to stop responding entirely until you power cycle the inverter (or unplug the network cable and reconnect it). This is only relevant if you have more than one modbus client accessing the inverter. Forcing all modbus requests from multiple devices through a single proxy that can serialize possible overlapping requests avoids this problem. So indeed, if you only have one thing accessing the inverter, adding a modbus proxy shouldn't make a difference.

githublakeware commented 2 months ago

Hast du die IP auch in der Secret yaml auf die IP von Homeassistent geändert?

Ja, habe ich. Ich habe wieder auf native umgestellt ohne Proxy. Mit proxy hatte ich viele Lücken in den Daten, es lief also nicht so gut.

jajaballard commented 2 months ago

Downgrade back to 2024.3.3: The entities are available for about 2h then they get unavailable again. I had the same behavior in 2024.4 after rebooting my sungrow converter.

Before I upgraded to 2024.4 initially, I had no problems with the sungrow entities

githublakeware commented 2 months ago

Next fix is planned for home-assistant/core 2024.4.4

andi-blafasl commented 2 months ago

https://github.com/home-assistant/core/pull/115279 is the issue with the upcoming fix for 2024.4.4

githublakeware commented 2 months ago

home-assistant/core#115279 is the issue with the upcoming fix for 2024.4.4

No: https://github.com/home-assistant/core/pull/115574

StoneMichael1 commented 2 months ago

After removing some unnecessary modbus values from the file i upgraded to 2004.4.3 and i have a stable modbus reading of all necessary values. I own a SH10RT and i know from iobroker it is not a good practice just to read ALL values from modbus but only the needed ones.

jajaballard commented 2 months ago

After removing some unnecessary modbus values from the file i upgraded to 2004.4.3 and i have a stable modbus reading of all necessary values. I own a SH10RT and i know from iobroker it is not a good practice just to read ALL values from modbus but only the needed ones.

So which one do you remove from the file? How long you call it stable? Could be helpfull for more people.

StoneMichael1 commented 2 months ago

I removed all the "yearly" and "monthly" registers. Actually i don't need so much. It makes sense to just read the registers that you use in HA for display or automation purpose. Stable for me is a consistent flow of readings without any modbus error in homeassitant logfile. And this is what i get now

Camp3r commented 2 months ago

I removed all the "yearly" and "monthly" registers. Actually i don't need so much. It makes sense to just read the registers that you use in HA for display or automation purpose. Stable for me is a consistent flow of readings without any modbus error in homeassitant logfile. And this is what i get now

good workaround, thanks for sharing! works fine for me and yes as you said, yearly and montly are not relevant.

githublakeware commented 2 months ago

I removed all the "yearly" and "monthly" registers. Actually i don't need so much. It makes sense to just read the registers that you use in HA for display or automation purpose. Stable for me is a consistent flow of readings without any modbus error in homeassitant logfile. And this is what i get now

good workaround, thanks for sharing! works fine for me and yes as you said, yearly and montly are not relevant.

Wow, this helps. First time that I have values for the missing entities, since I switched to HA 2024.04.

jajaballard commented 2 months ago

Sorry, but it is not working for me.

Camp3r commented 2 months ago

Sorry, but it is not working for me.

Did you reboot or restart your HA after update the modbus.yaml?

githublakeware commented 2 months ago

Sorry, but it is not working for me.

Did you reboot or restart your HA after update the modbus.yaml?

Yes, I updated the modbus_sungrow.yaml and then restartet HA. For some values, you have to wait for the full next hour to receive.

githublakeware commented 2 months ago

Sorry, but it is not working for me.

Did you reboot or restart your HA after update the modbus.yaml?

Yes, I updated the modbus_sungrow.yaml and then restartet HA. For some values, you have to wait for the full next hour to receive.

Sorry, the question was for jajaballard. I'm not really awake yet. :-)

jajaballard commented 2 months ago

Yes, I did a full restart. But this did not help. I figured out my Sungrow changed the IP adresse, so I need to correct the value in secrets.yaml. Now It works again!!!

Thanks for the workaround and your support!!

bumperboy commented 2 months ago

Home assistant 2024.4.4 installed and my Sungrow issue is fixed. thank you all for your help

Uschinator commented 2 months ago

Installed Home Assistant 2024.4.4 but still getting disconnected sometimes and then errors appear in the log:

`Logger: pymodbus.logging Quelle: runner.py:189 Erstmals aufgetreten: 08:00:24 (9 Vorkommnisse) Zuletzt protokolliert: 08:00:50

Failed to connect`

`Logger: homeassistant.components.modbus.modbus Quelle: components/modbus/modbus.py:318 Integration: Modbus (Dokumentation, Probleme) Erstmals aufgetreten: 07:49:47 (2 Vorkommnisse) Zuletzt protokolliert: 08:00:22

Pymodbus: SungrowSHx: Error: device: 1 address: 5007 -> Modbus Error: [Input/Output] ERROR: No response received after 3 retries`

And an error for automation: Error while executing automation automation.sungrow_inverter_update_battery_discharging_start_power_input_slider_update: expected float for dictionary value @ data['value']

This error happens to most of the sungrow automations.

Uschinator commented 2 months ago

And just now i got disconnected for 2 Minutes and every sensor or value displayed on the dashboard regarding sungrow was unavailable. So this issue is still not fixed.

AlexRitter commented 2 months ago

Updated to 2024.4.4 and all Values are currently present. Let´s see for a while what will happen....

InFlames82 commented 2 months ago

Updated to 2024.4.4 and get this error log:

Logger: homeassistant.components.modbus.modbus
Quelle: components/modbus/modbus.py:318
Integration: Modbus (Dokumentation, Probleme)
Erstmals aufgetreten: 08:21:38 (66 Vorkommnisse)
Zuletzt protokolliert: 09:22:45

Pymodbus: SungrowSH10RT: Error: device: 1 address: 12999 -> pymodbus returned isError True
Pymodbus: SungrowSH10RT: Error: device: 1 address: 13058 -> pymodbus returned isError True
Pymodbus: SungrowSH10RT: Error: device: 1 address: 13099 -> pymodbus returned isError True
Pymodbus: SungrowSH10RT: Error: device: 1 address: 33148 -> pymodbus returned isError True
Pymodbus: SungrowSH10RT: Error: device: 1 address: 13049 -> pymodbus returned isError True
githublakeware commented 2 months ago

@All: Please report your errors to HA/core.

githublakeware commented 2 months ago

I have now added all devices/entities to modbus_sungrow.yaml again, so I am using the original mkaiser yaml again. I currently get all values with HA/core 2024.4.4.