Giter VIP home page Giter VIP logo

mkaiser / sungrow-shx-inverter-modbus-home-assistant Goto Github PK

View Code? Open in Web Editor NEW
282.0 52.0 70.0 4.68 MB

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

homeassistant-integration inverter modbus sungrow yaml-configuration

sungrow-shx-inverter-modbus-home-assistant's People

Contributors

abredhauer avatar andi-blafasl avatar brettlynch123 avatar dst6se avatar dylan09 avatar dzarth avatar grandammor avatar housemaister avatar johschmitz avatar lapplandscohan avatar louisbertelsmann avatar mastameista avatar mkaiser avatar mmierke avatar stephan192 avatar tsopic avatar viktorreinhold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sungrow-shx-inverter-modbus-home-assistant's Issues

Featur request: `Total PV Power`

Currently Total DC Power is being calculated by the inverter incorrectly - this value is somehow influenced by other inverter, connected after smart meter.
In screenshot below, when my other inverter is idling, it should be around 688W, but only 563W is reported. There's no way 125W are lost to heat in inverter?!

So I suggest to add a sensor called Total PV Power, which is a sum of MPPT1 Power and MPPT2 Power.

Screenshot 2023-02-20 084222

Grid Frequency is too high by a factor of 10 (SH10RT)

Hello,

the frequency is displayed incorrectly.

image

  • name: Grid Frequency
    slave: !secret sungrow_modbus_slave
    address: 5035 # reg 5036
    input_type: input
    count: 1
    data_type: uint16
    swap: word
    precision: 2
    unit_of_measurement: "Hz"
    device_class: frequency
    state_class: measurement
    scale: 0.1 -> scale: 0.01
    scan_interval: 10

pv_info.yaml has wrong content

Since the last commit it seems that PV_Info.yaml actually contains the contents of modbus_sungrow.yaml, maybe you mixed something up?

Battery SoC Reserve don´t seem to work

I have a SH10RT and a SBR98 battery when i try to set the Battery SoC Reserve value nothing happens it remains at 0%, all the other set parameters seem to work fine.

Configure the inverter

Hi,
First of all, thank you so much for this, I just got an SH8.0RT and this integration is awesome.

I have a feature request, is it possible to set parameters over Modbus?
If so it would be great if we could set parameters like:

  • Force charging
  • Disscharge Weekday/weekend

Battery SoC Reserve is send in %

The value of reg 13100 Reserved SOC for backup is send as x %. You have defined it with scale: 0.1.
Should be scale: 1. Maybe a typo or related to copy & paste.

And the automation for setting the value should be modified.

Should also fix the value range error reported for this sensor in #35

Install method via HACS?

This integration is so cool, best I've found so far.
However I would like it to have a "standard" install method. It's not tooo difficult as it is now, but HACS would take care of updates.
Would do it myself, but it's a little too much.

SH10RT Master & Slave

Gibt es die Möglichkeit 2 Wechselrichter einzubinden wenn man die Konstellation im Master und Slave hat?

Differences SH*RT and SH*RS - battery capacity

I can retrieve the battery capacity for my SH10.RT with this register

 - name: Battery Capacity 
        slave: !secret sungrow_modbus_slave
        address: 33048  #33049 
        input_type: holding
        count: 1
        data_type: uint16
        swap: word
        unit_of_measurement: kWh
        device_class: energy
        scale: 10
        scan_interval: 600

bjeanes reported, that it does not work on an SH5.0RS #13 (comment)

It would be nice to have more support for the RS (not RT)

Are there any more differences?

Making sense of data - SH10RT

The inverter spits out a lot of data and some of it is difficult to understand. I hope we can collaborate on this to figure out what's what. Example below.

Q#1
Phase A/B/C current/voltage/power are zeros when there is no sun, and the sum of these powers are equal to Total DC power (when battery is not charging), so I'm guessing this is an internal thing, the output of DC/AC inverter, and is not an actual measurement done on any of external ports?

Q#2
Load power, meter active power and Export/import power don't match. Do we know what these numbers represent?
Meter power, I'm guessing comes from one of registers of inverter, and inverter is getting this data from meter itself? Can you confirm?
Export/import power. Where does this come from?
Load power - ?

Q#3
Backup power - ? In my case I have my whole house connected to Backup port of the inverter and I expect this to be equal to Load power, and for sure there should be no negative values in the phases, right? Unless is some kind of internal thing again.

Untitled

incorrect battery voltage, stuck SOC

I was playing with inverter modes, tried force charge and force discharge. I see there are two issues.

  1. SOC is stuck at 100%, even after several hours of discharge. Weirdly, physical battery SOC bar shows 100%. Is this bug in firmware of battery/inverter? Can anyone test and report back? I see this in HA, but also in iSolarClour app?!
    Screenshot_2022-12-04-18-17-14-378_com isolarcloud manager-edit

  2. Incorrect battery voltage. Basically, the battery is of LFP chemistry, which means cell voltage at 0% SOC is 2.0V, and 3.65V at 100% SOC. I see 204V at 100% SOC, so it should be around 111V at 0%. But I see 187V. This is wayy off. I see the same thing in the app.
    I have previously noticed that battery power is way off from current * voltage.
    Screenshot_2022-12-04-18-04-29-452_io homeassistant companion android-edit

So it's clearly not an issue with this integration, but what is happening? Can anyone check on their setup?

None of the configuration works

For me, none of the configuration stuff works. I‘ve also got a SH10RT inverter, but it just won‘t work. I tried to set the device to force charge, but none of the options seem to work. I‘ve tried it in the normal self-consumption mode and also the forced mode. The automation gets triggered, so I don‘t think that‘s the problem. It must be somewhere between the modbus config and the inverter. I‘m also running the code version from the 20th january 2023.

Current code issues, future plans

Future work items and disussion about code quality

Discussions, suggestions and help are much appreciated. I have not very much free time at the moment to check address all this by myself. So I will just write down what is in my mind right now :)

  1. use "unique_id" for every sensor. With a unique_id, every sensor can be edited via GUI (this feature was not yet available, at first release of this integration)
    When this is completed it is possible to MANUALLY ( :/ ) assign each value a room. In the Dashboard the sungrow inverter values would be grouped in that room and the values would not be randomly spread among the "generic sensors"

  2. Find a way to hide some values like the internally used "device type", from which the user-readable device strings are derived in a template sensor.
    They have a unique_id now, so at least they can be hidden by the user via GUI.

  3. Search for alternatives to set the user-specific parameters (IP, slave address, port) outside the .yaml configuration files and outside the secrets.yaml (currently it is there).

  4. Find a way to read parameters for maximum battery charge (inverter requests that value from battery at run-time). Then use this value to set range of the maximum battery charge current.

  5. Provide a second yaml file for slave inverters #43

  6. Collect more dashboard examples from users (see cdaa5e8)

  7. Document, how to write own automations, as asked here: #50 (comment)

  8. Maybe split current sungrow_modbus.yaml into multiple files (e.g. Base, Battery, History), #65

Most of that would look like an ABI-change and users cannot simply upgrade by replacing the .yaml files. Should be something for a testing / v2 branch then.

Not working with SH6.0RS

I'm trying to make your integration working with my Sungrow SH6.0RS Hybrid Inverter but all the sensors return a "Not available" warning and I can't get the read values. I checked all the parameters (IP, port, slave) which are correct. How can I solve the problem?

Weird data reported by SH10RT

It's not an issue, just a question if you see this too. I'm noticing that numbers don't add up (with other integration I used before it was the same).

First of all, when inverter is active (battery charge/discharge or solar conversion), I get nice numbers that align perfectly, I mean input power = output power. This is impossible however, as there are conversion losses. So I'm certain there is some fakery going on.

Second, I noticed that battery power is wayyyy off of what I get by multiplying battery current * voltage.

Third, I'm seeing this weird "active power" of around -95W, which does not add up with other readings. In my example below, solar power is zero, battery power is zero, and input/output power is equal. So the sum zeroes out, right? However, during the day there is this -95W. I have checked and it almost exactly matches sunrise and sunset time where I live. Also, when this starts and ends, there is no change in in/out power, and also the inverter does not heat up. So this is a ghost, non-existing power. Weird right, it's almost as if it has a schedule and does some extra fakery?
Screenshot 2022-12-01 223147

And fourth... I have an extra solar plant that is connected to the output of this inverter, parallel to the house. By output, I mean "backup" port, which I use to supply whole house.
Couple months back, when solar power from that second plant was higher than what my house uses, "Load power" would decrease to zero and stay there, it would not go negative, even though power is flowing back to the grid. More fakery.

homeassistant zeigt nicht alles an, was mache ich falsch?

Hallo Herr Kaiser , erst mal vielen Dank für die Integation des Sungrow WR in Homeassistant.
Leider wird nicht alles angezeigt siehe Anhang.
Auch werden die Binäeren Werte nur mit off angezeigt. Habe heute das neue Update für den SH10RT gemacht, hat keine Änderung gebracht.
Haben Sie eine Idee was da nicht stimmt?

Vielen Dank im Vorraus

André

Sungrow2

Limit max charge/discharge of battery

I integrated a sensor for register 33046 "Max charge power"

      - name: Battery Max Charge Power
        slave: !secret sungrow_modbus_slave
        address: 33046 # 33047
        input_type: holding
        count: 1
        data_type: uint16
        swap: word
        precision: 0
        unit_of_measurement: W
        device_class: power
        state_class: measurement
        scan_interval: 10

and a realting input_number

  set_sg_charge_discharge_power_percentage:
    name: max charge discharge power in W
    #initial: 40
    min: 0
    max: 5000
    step: 50

Integrated into the dashboard by

  - entity: input_number.set_sg_charge_discharge_power_percentage
  - entity: sensor.battery_charge_discharge_power

Idea is to limit charging to 1W until 12am if forecast for the day is more than 20 kWh for example. So the 70% cut can be used to charge the battery .
Unfortunately this doesn't work in EMS "Self consumption mode", I have to change to forced mode.
Does anybody know a solution? I don't want to change EMS mode.

Unknown device code

I've previously had a working installation of this integration bit from some time ago it can't connect to the inverter (SH10RT).

07A50C84-EB4D-4E8E-B0B6-D09143DC6183

I have the latest version of the integration installed.
Firmware in inverter was updated automatically on the 22nd of November. Can't figure out what version was installed.

Any help appreciated. Thanks.

Modbus error in log files: Received 2 bytes, unpack error unpack requires a buffer of 4 bytes

I received many errors in the log since the last updates last week.

2023-01-29 00:34:49.352 ERROR (MainThread) [homeassistant.components.modbus.base_platform] Received 2 bytes, unpack error unpack requires a buffer of 4 bytes
2023-01-29 00:34:49.372 ERROR (MainThread) [homeassistant.components.modbus.base_platform] Received 2 bytes, unpack error unpack requires a buffer of 4 bytes

needs more investigation. On the first view it looks like a register of 2byte / 16 Bit is read, but 4 bytes / 32 bit are expected.

--> successivly comment registers with 32 bit and check the log....

Help would be much appreciated - I am short on time the next weeks

Create two dashboards: One for status and for settings

I accidentally moved sliders, when I just wanted to get status information.

It would be good to have two Sungrow Inverter dashboards:

  • Sungrow Status
  • Sungrow Settings (Danger Zone!)

It is not very high on my ToDo List... Help much appreciated :)

Two inverters

First off, great work!

I have two SH10RT, is it possible to add both? I only have battery on one of them, the master, and that works like a charm but for information like current solar power, daily yield and such its not enough to add the master as it doesn't show the stats from the slave.

Automation for switching EMS Mode and battery forced charge // maybe tibber as trigger

Hey guys, I learned a lot about this great integration of my SH10RT-v112 in HA. Thanks for your constructive discussion : )

Now I'm trying to write a automation which can
switch
the ems mode from sensor.ems_mode_selection_raw = 0 (Self-consumption mode) to 2 (Forced mode)
AND
the battery forced charge/dischrage cmd sensor.battery_forced_charge_discharge_cmd_raw = 0xCC (Stop) to 0xAA (Forced charge)
if
my tibber-integration-sensor sensor.electricity_price_home states a value like 0,30 EUR/kWh.

After one hour the switch should change back to self consumption mode and forced mode stop. Can you help me with the yaml for that "Modbus:write register"-action?

Maybe there will be smarter versions but I think this would be a good start...?!

SH5K-30 works

Hello, you mentioned that you would like feedback on if this works with the SH5K-30. I got this working successfully. Thanks for posting this as without your guide I would have never been able to pull this data into HA.

Winet-S

I just got this message from Sungrow

The Modbus TCP is added to the latest FW version of the WiNet dongle.

Med vänliga hälsningar | Best Regards

William Strijks
Service Manager Sweden

Does it work with Winet-S, has anyone tested

Battery Charge / Discharge

Would it be possible to have separate entitys for charging and discharging of the battery? Or one entity that's negative when the battery is discharging and positive when the battery is charging.
I don't really know much about templating in Home Assistant, but figured it could be done using the Binary Sensors relying on Running State.

Error handling

I just figured out my battery is failing, error 833 and some others. I can force-charge it, but can't discharge, it will just ignore the command. Same in self-consumption mode. Inverter status is unchanged and I don't get any feedback that something is wrong, it just ignores me.
I am discussing this with sungrow support.

Would it be possible to read errors/status from the inverter somehow?
Anyone has info what running/system state codes mean?

Those are decimal, but probably binary underneath.
My running state is changing between:
00101000 (40)
00001100 (12)
00101010 (42)
17, 41, 43 32, 0 etc....

Request: Be able to set Energy Management Parameter

I'd love to be able to set the parameters for the energy management if possible some how.
This would allow to automatically charge the battery from the sun or the grid depending on which is cheaper that particular day.
I know that i can just change EMS Mode if i don´t want to charge the battery from the sun but if i still would like to use the battery instead of the grid if the sun goes away in a cloud or something I'd have to change EMS mode quite often depending on the actual solar production and price instead of just the price. Id suspect that it´s not that god for the system to manually set EMS mode efery few minutes in worst case.

Example:
Between 07:00-20:00 I'd like to use self-consumption mode to use the energy in the battery instead of buying from the grid. I'd also like to charge the battery from the sun only if the price is lower than X money (0.95 SEK in my case).
Therefore I'd like to check every full hour if the price is over X money and then set Forced charge percentage to 0 if true, otherwise to 100%. I also have a "backup" that charger the battery at night if not already full.

image

Can't change inverter mode

I want to control when the battery is charged/discharged. It's set to "self consumption" by default, and setting forced charge/discharge did not work.
Tried to change mode to "external EMS", and this does not work (setting won't change).

Also "battery charging start power" and "battery discharging start power" is incorrect 2^16.

run mode

Edit: I was able to change mode after multiple tries and inverter restart (stop, start). Will investigate further.

Exporting Power not working

After a few weeks with very little sun, today my battery was fully charged and the Inverter (SH6.0RT connected directly via eth, not through winet-s) started exporting power. But in HA there is no info about that. The Binary Sensor did not show and the exporting value is always zero.
Here's a screenshot from the day:
image
as you can see, binary sensor for importing is working as expected. Any Ideas what's going wrong?

Not working on SH6.0RT

Version: Home Assistant 2022.12.8

I get no data from my SH6.0RT inverter.
I can see this errors in the home-assistant.log

2023-01-05 22:34:47.674 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ (states('sensor.mppt1_voltage') | float * states('sensor.mppt1_current') | float) |int }}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1710, 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 423, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1942, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1713, in forgiving_float_filter
    raise_no_default("float", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1411, in raise_no_default
    raise ValueError(
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.mppt1_voltage') | float * states('sensor.mppt1_current') | float) |int }}' 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 540, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 425, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.mppt1_voltage') | float * states('sensor.mppt1_current') | float) |int }}' but no default was specified
2023-01-05 22:34:47.686 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.mppt1_voltage') | float * states('sensor.mppt1_current') | float) |int }}' but no default was specified') while processing template 'Template("{{ (states('sensor.mppt1_voltage') | float * states('sensor.mppt1_current') | float) |int }}")' for attribute '_attr_native_value' in entity 'sensor.mppt1_power'
2023-01-05 22:34:47.701 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ (states('sensor.mppt2_voltage') | float * states('sensor.mppt2_current') | float) |int}}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1710, 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 423, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1942, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1713, in forgiving_float_filter
    raise_no_default("float", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1411, in raise_no_default
    raise ValueError(
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.mppt2_voltage') | float * states('sensor.mppt2_current') | float) |int}}' 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 540, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 425, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.mppt2_voltage') | float * states('sensor.mppt2_current') | float) |int}}' but no default was specified
2023-01-05 22:34:47.705 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.mppt2_voltage') | float * states('sensor.mppt2_current') | float) |int}}' but no default was specified') while processing template 'Template("{{ (states('sensor.mppt2_voltage') | float * states('sensor.mppt2_current') | float) |int}}")' for attribute '_attr_native_value' in entity 'sensor.mppt2_power'
2023-01-05 22:34:47.711 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ (states('sensor.phase_a_voltage') | float * states('sensor.phase_a_current') | float) |int}}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1710, 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 423, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1942, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1713, in forgiving_float_filter
    raise_no_default("float", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1411, in raise_no_default
    raise ValueError(
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.phase_a_voltage') | float * states('sensor.phase_a_current') | float) |int}}' 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 540, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 425, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.phase_a_voltage') | float * states('sensor.phase_a_current') | float) |int}}' but no default was specified
2023-01-05 22:34:47.716 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.phase_a_voltage') | float * states('sensor.phase_a_current') | float) |int}}' but no default was specified') while processing template 'Template("{{ (states('sensor.phase_a_voltage') | float * states('sensor.phase_a_current') | float) |int}}")' for attribute '_attr_native_value' in entity 'sensor.phase_a_power'
2023-01-05 22:34:47.719 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ (states('sensor.phase_b_voltage') | float * states('sensor.phase_b_current') | float) |int}}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1710, 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 423, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1942, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1713, in forgiving_float_filter
    raise_no_default("float", value)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1411, in raise_no_default
    raise ValueError(
ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.phase_b_voltage') | float * states('sensor.phase_b_current') | float) |int}}' 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 540, in async_render_to_info
    render_info._result = self.async_render(variables, strict=strict, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 425, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.phase_b_voltage') | float * states('sensor.phase_b_current') | float) |int}}' but no default was specified
2023-01-05 22:34:47.725 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ (states('sensor.phase_b_voltage') | float * states('sensor.phase_b_current') | float) |int}}' but no default was specified') while processing template 'Template("{{ (states('sensor.phase_b_voltage') | float * states('sensor.phase_b_current') | float) |int}}")' for attribute '_attr_native_value' in entity 'sensor.phase_b_power'
2023-01-05 22:34:47.729 ERROR (MainThread)

Feature request, control of charging and allow discharging of battery.

I would like to know if there is a possibility to include the registers for force charging and allow of discharging of the battery at specific times. Use case would then be to find the cheapest hours (ie during the night) to charge the battery and then find the best time to use the battery to cut off peak prices.

Does anyone know if this is possible to do at all?

Feature Request to add Grid Voltage & Frequency Parameters

Hallo,
I have added the following ModBus paramters to also monitor Grid Voltage & Frequency. Maybe you also add this to modbus_sungrow.yaml.

  - name: Phase A Voltage
    slave: !secret sungrow_modbus_slave
    address: 5018
    input_type: input
    count: 1
    data_type: int16
    swap: word
    precision: 1
    unit_of_measurement: V
    device_class: Voltage
    state_class: measurement
    scale: 0.1
    scan_interval: 10

  - name: Phase B Voltage
    slave: !secret sungrow_modbus_slave
    address: 5019
    input_type: input
    count: 1
    data_type: int16
    swap: word
    precision: 1
    unit_of_measurement: V
    device_class: Voltage
    state_class: measurement
    scale: 0.1
    scan_interval: 10

  - name: Phase C Voltage
    slave: !secret sungrow_modbus_slave
    address: 5020
    input_type: input
    count: 1
    data_type: int16
    swap: word
    precision: 1
    unit_of_measurement: V
    device_class: Voltage
    state_class: measurement
    scale: 0.1
    scan_interval: 10

  - name: Grid Frequency
    slave: !secret sungrow_modbus_slave
    address: 5035
    input_type: input
    count: 1
    data_type: int16
    swap: word
    precision: 1
    unit_of_measurement: "Hz"
    device_class: frequency
    state_class: measurement
    scale: 0.1
    scan_interval: 10

Feature request, Power per MPPT controller

Would it be possible to create a sensor that displays the current power in watts per MPPT controller? It don´t seem to be any in the modbus register documentation but it would be possible to calculate by multiplying current with voltage?

Deactivate/ hide battery features

Hi,
first of all: Thanks for your great work!

I have a SH8.0RT and it's working great for me. Althought it was hard to find out, that I have to use the second LAN port next to the WiNet-S dongle to make it work. (BTW: Is there anywhere a guideline how to upgrade firmware for Sungrow? I only found outdated descriptions, which are not working for me.)

The question/ feature request I really have is the following:
I don't have a battery and I would like to deactivate or hide all battery functionallities.

Would be great to have a central parameter instead of going through all lines of code to deactivate.

Best regards,
Iven

2nd inverter

Hello! Is ist possible to integrate a 2nd inverter? I have two (Sungrow SH10RT), each with a battery. Actually your project works fine, but i see only values from one inverter...
Thanks!!

Incorrect value ranges

Correct value ranges for SH10RT are:
Max SOC: 50-100%
Min SOC: 0-50%
Battery SOC reserve: 0-10% (won't accept more than 10%)
Max charge/discharge power: 10.6 kW
Max forced charge/discharge is probably 10.6 kW as well.
(I have a 22 kWh battery)

Screenshot 2022-12-18 125553
Screenshot 2022-12-18 125646

GUI to read/set any register

I would love to have a way to debug my system by setting or reading any register.
Also this would (possibly?) allow us to totally ditch the iSolarCloud and fully set up the inverter locally.

For example I want to know min/max/avg battery cell voltages (registers 13112-13114), min/max cell temperatures etc.
Also would be interesting to play with Load timing registers 13009 etc.
I understand I am probably the only one here with sungrow SBR battery?? So It's obvious not everyone needs this. Some even want no battery data at all.
I also understand I can make a script with modbus.write_register service call myself, but perhaps this could be a good idea to include a simple GUI in the dashboard?
One number input for register number, one input for data and button Write, one data with button Read.
Or just a script that does this?

Simplify setup by removing secrets

I replaced all the secrets in the yaml file in order to make the setup easier. After all they are no secrets just an IP and a port number. I suggest you also do that and simplify the documentation accordingly.

Max. charge and discharge power. 0 is invalid value.

The value 0 is not valid for sg_battery_max_charge_power and sg_battery_max_discharge_power.
Setting register to 0 leads to error Pymodbus: SungrowSH10RT: Exception Response(134, 6, SlaveFailure).

iSolarCloud shows 0.01 ~ 10.6 as valid range. So minimum value for input_numbers set_sg_battery_max_charge_power and set_sg_battery_max_discharge_power should be >= 10.

My suggestion would be minimum of 100. Equal to the step size.

Rework Overview Dashboard

I'm making some tests for a nice visual overview Dashboard. Feedback would be nice.
Maybe gauges and badges:
image

and / or diagram and glances:
image

It is a bit difficult to get a nice looking layout without any custom cards and layout mods. But I'm very new to it and climbing the learning curve ;-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.