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
307 stars 80 forks source link

SH10RT Master & Slave #43

Open Matze5593 opened 1 year ago

Matze5593 commented 1 year ago

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

elektrinis commented 1 year ago

Good question. I will be installing a second one soon.

Can we keep this in English please.

mkaiser commented 1 year ago

hey,

that should work. See https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant/issues/16

Recently, one guy in the home assistant forum confirmed that he got it working: https://community.home-assistant.io/t/sungrow-sh10-rt-modbus-integration/361356/35

Matze5593 commented 1 year ago

Unfortunately, the method described in #16 does not work. i tried to avoid duplicate names by using the designation 2 or slave. but dying didn't help. modbus_sungrow2.yaml.txt

mkaiser commented 1 year ago

copied this together with just 2 sensors, but I obviously cannot check without a second inverter, so I need your help here :)

When this works, the next step is more or less copy / paste for the other sensors

  1. copy the file (modbus_sungrow_inv2.yaml) next to the existing file (modbus_sungrow.yaml) in the integrations folder
  2. update your secrets.yaml accordingly (see the comments of modbus_sungrow_inv2.yaml
  3. Check and restart HA

modbus_sungrow_inv2.yaml.txt

leo4417 commented 1 year ago

This works with my two SH10RT! I've completed the 2nd yaml, see below.

modbus_sungrow2.yaml.txt

I have an additional question: when I try to write a modbus register like this, it's not working. Do you have any idea? Actually the "Set battery SoC reserve" doesn't work either. Perhaps the same problem?

alias: Battery-SoC 17
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.battery_level
    above: 90
condition: []
action:
  - service: modbus.write_register
    data:
      address: 13100
      hub: SungrowSHx
      slave: 2
      value: 17
mode: single
mkaiser commented 1 year ago

great to know that this is working.

I will put this on the "ToDo" list, but final integration and documentation will take some time.

If you want to write to modbus register 13100 (reserved soc for backup), you need to decrement the address to 13099

copied from modbus_sungrow.yaml (arount line 1470)


    alias: "sungrow inverter update reserved soc for backup"
    description: "Updates reserved SoC for backup register"
    trigger:
      - platform: state
        entity_id:
          - input_number.set_sg_reserved_soc_for_backup
    condition: []
    action:
      - service: modbus.write_register
        data_template:
          hub: SungrowSHx
          slave: !secret sungrow_modbus_slave
          address: 13099 # reg 13100
          value: "{{ states('input_number.set_sg_reserved_soc_for_backup') | int}}"
    mode: single```

Does this help?
leo4417 commented 1 year ago

Yes, it works! Thanks!! But for example, if I enter value: "70" the Battery SoC reserve (sensor.battery_soc_reserve) displays 7%, with "90" this changes to 9%, values above 100 have no effect. Where is my mistake?

leo4417 commented 1 year ago

This is known, I haven't seen it..

      - name: Battery SoC reserve 2
        unique_id: sg_battery_soc_reserve_2
        slave: !secret sungrow_modbus_slave_inv2
        address: 13099 # reg 13100
        input_type: holding
        count: 1
        data_type: uint16
        swap: word
        unit_of_measurement: "%"
        device_class: battery
        state_class: measurement
        scale: 1 **# NOT 0.1**
        scan_interval: 10
leo4417 commented 1 year ago

I tried to adjust the max_charge_power because battery system SunGrow SBR265 supports up to 17.520 W Unfortunately this doesn't work... Perhaps the register isn't correct?

  set_sg_battery_max_charge_power:
    name: Set max battery charge power in W
    #initial: 40
    min: 0
    max: 17520
    step: 100

  set_sg_battery_max_discharge_power:
    name: Set max battery discharge power in W
    #initial: 40
    min: 0
    max: 17520
    step: 100
Matze5593 commented 1 year ago

In the secret.yaml, the slave inverter must be set as a Modbus slave from 1 to 2 in order to be able to query data via the sh10rt's Modbus port

z.B

`

first inverter Master

sungrow_modbus_host_ip: 192.168.178.xx sungrow_modbus_port: 502 sungrow_modbus_slave: 1

########################################################################

second inverter Slave

sungrow_modbus_host_ip_inv2: 192.168.178.xx sungrow_modbus_port_inv2: 502 sungrow_modbus_slave_inv2: 2 `

bleughb commented 1 year ago

This works with my two SH10RT! I've completed the 2nd yaml, see below.

modbus_sungrow2.yaml.txt

I have an additional question: when I try to write a modbus register like this, it's not working. Do you have any idea? Actually the "Set battery SoC reserve" doesn't work either. Perhaps the same problem?

alias: Battery-SoC 17
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.battery_level
    above: 90
condition: []
action:
  - service: modbus.write_register
    data:
      address: 13100
      hub: SungrowSHx
      slave: 2
      value: 17
mode: single

Thankyou. Your YAML file worked perfectly for my TWO SG5.0RS I'd spent a couple of hours trying to create a second modbus_sungrow.yaml file to handle two inverters! Now I can plot my 4 MPPT string currents

bleughb commented 1 year ago

Quick heads up RE the dual YAML files - reduce increase the scan_interval time ...the default will flood the Winet-s devices and knock them offline. i've taken mine to 60s at the moment and will see how it goes

Matze5593 commented 10 months ago

hi, i have problems with the power mppt 1/2. I don't understand how the code works and my mistake lies. I just don't get any values ​​for the power. Could you please help me

`

name: MPPT2_inv2 power unique_id: sg_mppt2_power_inv2 unit_of_measurement: W device_class: power availability: "{{states('sensor.mppt2_voltage_inv2')|is_number and states('sensor.mppt2_current_inv2')|is_number }}" state: "{{ (states('sensor.mppt2_voltage_inv2') | float * states('sensor.mppt2_current_inv2') | float) |int }}"

leo4417 commented 10 months ago

Since the last update i get no data from my second inverter... Does anybody have an idea?

Wolkenstuermer commented 10 months ago

Last HA Update broke my complete Sungrow INtegration for SH and SG... Think there are some issues between Modbus in HA Core and the Code (there is something with regards to uint/int16 needs swap: none ... but this did not help...

I will get deeper into this during the next week.

dylan09 commented 10 months ago

Are you using the latest version of modbus.yaml file? There the error with swap is fixed.

Since HA 2023.9.x there are some new, weird ModBus issues. See 158

There you will find a link to the HA issue regarding the problems with ModBus.

roennieinator commented 9 months ago

I created a .yaml config file for my second inverter that works with Home Assistant 10.1. I only included the sensors I really need, so of you like, feel free to complete the file - I was too lazy :)

If you want to use this, please follow the instructions given earlier in this thread. Thanks to @bleughb for the "inspiration" (I basically stole your way of doing the config).

second_inverter_version_10_1.yml.txt

howi303 commented 2 months ago

Has anyone two SH10RT-V112 as Master/Slave working and both combined shown in a flow chart?