I am very much a newbie with this, I didn’t realise that HA already supported Modbus, nor understand the need to add the code to configuration.yaml. I am very much a graphical user!
I am now using Modbus Client app (on my Mac) to test if I can retrieve any data. I suspect that I may have issues due to the encryption that has been reported being used by Sungrow.
But you have certainly answered the immediate question
That may be as far as I can take you. I’m still waiting for my Sungrow inverter and solar to be installed at end of month! I am also anticipating some issues with encryption but hopefully we can overcome them !
I installed the ModbusTCP2MQTT successfully. Thanks for your tip. It is sending requests, but I am getting errors, which I suspect may be due to the fact that Sungrow have now implemented encryption.
I have found this project rpvelloso/Sungrow-Modbus which adds encryption to the standard ModbusTCP client, by " just replace ModbusTcpClient() with SungrowModbusTcpClient()".
I couldn’t figure out how to do that, and I have created a new thread how to swap the standard TCP with the encrypted one. The thread is " TCP Client for Sungrow Devices with encryption"
@mkai, Thank you a lot for sharing this awesome code.
I have a SH10RT with battery and WiNet-S. If somebody else is struggeling a bit, modbus with LAN was working fine for me from the beginning.
WLAN started to work after a firmware update in my case:
If the Battery charging sensor works, it should be relatively easy to create a template sensor (look at the lower part of the modbus_sungrow.yaml for examples)
Hi Martin, thank you very much for your reply and your effort for the integration. I already solved it using a battery load trend sensor checking, if % load goes up or down. Works like a charm.
Anyway I will check your updated version and let you know.
I noticed that battery current was negative when charging, so I did the following:
modbus:
- name: SungrowSHx
# ...
sensors:
- name: Inverter battery power (raw)
unique_id: inverter_battery_power_raw
slave: !secret sungrow_modbus_slave
address: 13021
input_type: input
count: 1
data_type: uint16
swap: word
precision: 0
unit_of_measurement: W
device_class: power
state_class: measurement
scale: 1
scan_interval: 10
- name: Inverter battery current
unique_id: inverter_battery_current
slave: !secret sungrow_modbus_slave
address: 13020
input_type: input
count: 1
# data_type: uint16
data_type: int16 # docs say unsigned but I'm getting overflows when battery is charging
# changing to int shows negative amperage which makes sense.
swap: word
precision: 1
unit_of_measurement: A
device_class: current
state_class: measurement
scale: 0.1
scan_interval: 10
sensor:
- platform: template
sensors:
inverter_battery_power:
unique_id: inverter_battery_power
friendly_name: Inverter battery power
value_template: >-
{% set current = states('sensor.inverter_battery_current') %}
{% set power = states('sensor.inverter_battery_power_raw') %}
{% if 'unavailable' in [current, power] %}
unavailable
{% elif current|float < 0.0 and power|float > 0.0 %}
{{ -1 * power | float }}
{% else %}
{{ power | float }}
{% endif %}
unit_of_measurement: W
device_class: power
Edit: I had to change the data_type on the battery current to be int16, despite what Sungrow docs show. Also, from talking to other people, the value ranges in these registers might vary based on the actual battery pack you have. In my case, I have a SH5.0RS with SBR128 battery.
I’ve managed to get this config up, however the on/off sensors are not working for me either, has anyone find a solution for this?
I’ve also a question regarding to charge the battery. I want to specify a certain time to charge the battery from the grid (depending on price of electricity), how do I force the system via HA to charge the battery from the grid?
Hey @mkai,
The SH10RT has a DO relay that is a part of its load control, did you see it in your modbus scan? as I can’t see it anywhere. I also don’t seem to be able to scan my inverter with any modbus tool but your integration works and gets data so it must be working.
Hello, Thank you for your work. I have an SH10RT. I can access it via LAN-Interface as “User” and as “Admin”. But the integration is’nt delivering any value.
I have triple-checked the ip-address, modbus-port and slave-settings.
There was an issue on github for that. Unfortunately the thread starter did not share his processings. Feel free to re-open it
@ [CodeRed]
Best to check the github page (especially the issues) for that.
I would start updating to the current firmware. Next step is to ensure, that you are using the SH10.RT’s native LAN port, NOT the LAN port of the dongle.
Then use some modbus TCP tool (search: modbus tool, windows / linux) to check the address and slave port.
@mkai Thank you for the great work. Importing data from inverter (SH10RTV112) worked like a charme.
Saved me a lot of time and work
Only thing I would suggest for future users: Maybe you could add a hint to use the local LAN Port. Not the WiNet port. Also with current firmware the WiNet port has not all ModbusTCP capabilities. Some registers aren’t available. Even some are erroneous. E.g. grid frequency has divisor 0.01 and not 0.1 as documented.