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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undocumented Holding Registers destroys SH10RT Config

DemigodCode opened this issue · comments

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

Describe the bug:

The undocumented holding registers of the Inverters destroys the configuration of my inverter.
If I use one of them, they are overwritting a couple of settings and make the inverter not discharge the battery anymore until I load configuration defaults of the inverter.
The holding register discharge is not the same as the input register one.
It seems like it's destroyed after changing the min soc too.

Model: SH-10.RT v112

  • LAN (internal port)

  • [] WiNet-S (LAN) (connected but not used for Modbus)

  • Are you using a Modbus Proxy (mark one)

    • [] yes
    • no
    • [] I don't know what that is

Home Assistant version:

  • Version: 2024.1.6

modbus_sungrow.yaml:

  • Version/ time stamp : [e.g. 2023-09-08] (see header of the file)
  • [] I ensured to use the most recent version

** Inverter Firmware Status:**

  • I made sure that the newest firmware is installed via the installers account

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Overview'
  2. Scroll down to 'Helpers'
  3. Set max battery discharge power

Expected behavior
They should be marked as EXPERIMENTAL... That took me so much of my time to figure out what the problem is and what it did change.

Screenshots
image
image

Hi,

sorry to hear that!

Could you describe in more detail what happened? Strange thing is that I recently installed one SH10.RT rev112 myself for a friend. All the set* functions worked fine via GUI sliders.

I will make some updates soon and ensure to write a comment on each undocumented sensor.
In the current version 1.1.2 of the modbus procotoll documentation the max charging and discharging power parameters are now documented. So they should not cause your issues.

image

This leaves following registers as possible culprits:
- name: Reserved SoC for backup
- name: Battery capacity
- name: Battery charging start power
- name: Battery discharging start power

Could you test max charging and discharging registers?

Was anything regarding the other registers in the HA log files?

Can I somehow back up all settings using modbus?

I only have a user iSolarCloud account so I cannot back them up there and don't want to have my electrician to set it up again. ;-)

Don't know which parameter caused this. And don't know how to figure out.

If I change a parameter through modbus does it send the whole configuration again or the parameter to change only? I don't have much knowledge about the modbus protocol.

Do you have an idea why the holding register values differs to the other one?

unfortunately, its not easily possible via modbus (possible, but involves some work).

it is easier via isolarcloud: you can backup the current settings by logging in to isolarcloud via installers account. if you don't have one, create one with another email address. Sungrow does not check, if it is an anctual company behind installers accounts or not.

I assume the set parameters from the installers are

  • installed PV power
  • export power limit (should be '0', meaning no power limitation)
  • battery parameters (kWh, min/max charge {power, Soc}, backup )

Okay, I've got the time to set up a anstaller account and to create a template of my parameters.

But in HomeAssistant it's like it's not reading the parameters as it should. Logs look like that:

`
2024-05-04 22:06:02.836 WARNING (MainThread) [homeassistant.components.modbus.modbus] modbus SungrowSHx communication closed
2024-05-04 22:06:03.062 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({{ (states('sensor.total_imported_energy_cost')) | float |round(2) }}) renders=2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1984, in forgiving_float_filter
return float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 567, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2305, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "", line 1, in top-level template code
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1987, in forgiving_float_filter
raise_no_default("float", value)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1625, in raise_no_default
raise ValueError(
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.total_imported_energy_cost')) | float |round(2) }}' but no default was specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 693, in async_render_to_info
render_info._result = self.async_render(
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 569, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.total_imported_energy_cost')) | float |round(2) }}' but no default was specified
2024-05-04 22:06:03.074 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.total_imported_energy_cost')) | float |round(2) }}' but no default was specified') while processing template 'Template<template=({{ (states('sensor.total_imported_energy_cost')) | float |round(2) }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.daily_imported_energy_cost'
2024-05-04 22:06:03.075 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.daily_exported_energy_compensation (<class 'homeassistant.components.template.sensor.SensorTemplate'>) is using native unit of measurement '€' which is not a valid unit for the device class ('energy') it is using; expected one of ['MJ', 'MWh', 'Wh', 'kWh', 'GJ']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+template%22
`

And now to show you what the difference is:

image

image

The Min SoC looks strange too with two different values:
image
Current iSolarCloud: 10%

Am I missing something?

Cannot find (states('sensor.total_imported_energy_cost')) in this repositories YAML file. I guess the error comes from somewhere else. Can you double-check?

image
image

The max battery charge / discharge entities come with a default maximum of 5000 W since @mkaiser can't know your actual battery size / parameters.
You should adjust it to match your actual battery parameters. I assume it will then display the correct value.

You can find them here: https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant/blob/main/modbus_sungrow.yaml#L2325
and here: https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant/blob/main/modbus_sungrow.yaml#L2331