Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SH10RT Master & Slave #43

Open
Matze5593 opened this issue Jan 14, 2023 · 27 comments
Open

SH10RT Master & Slave #43

Matze5593 opened this issue Jan 14, 2023 · 27 comments

Comments

@Matze5593
Copy link
Contributor

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

@elektrinis
Copy link

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

Can we keep this in English please.

@mkaiser
Copy link
Owner

mkaiser commented Jan 14, 2023

hey,

that should work. See #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
Copy link
Contributor Author

Matze5593 commented Jan 16, 2023

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
Copy link
Owner

mkaiser commented Jan 17, 2023

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

@mkaiser mkaiser mentioned this issue Jan 20, 2023
@leo4417
Copy link

leo4417 commented Jan 26, 2023

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
Copy link
Owner

mkaiser commented Jan 27, 2023

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
Copy link

leo4417 commented Jan 27, 2023

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
Copy link

leo4417 commented Jan 27, 2023

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
Copy link

leo4417 commented Jan 28, 2023

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
Copy link
Contributor Author

Matze5593 commented Feb 7, 2023

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
Copy link

bleughb commented May 26, 2023

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
Copy link

bleughb commented May 28, 2023

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
Copy link
Contributor Author

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: MPPT1 voltage inv 2
    unique_id: sg_mppt1_voltage_inv2
    slave: !secret sungrow_modbus_slave_inv2
    address: 5010 # reg 5011
    input_type: input
    count: 1
    data_type: uint16
    swap: word
    precision: 1
    unit_of_measurement: V
    device_class: Voltage
    scale: 0.1
    scan_interval: 10

    • name: MPPT1 current inv 2
      unique_id: sg_mppt1_current_inv2
      slave: !secret sungrow_modbus_slave_inv2
      address: 5011 # reg 5012
      input_type: input
      count: 1
      data_type: uint16
      swap: word
      precision: 2
      unit_of_measurement: A
      device_class: Current
      scale: 0.1
      scan_interval: 10

    • name: MPPT2 voltage inv 2
      unique_id: sg_mppt2_voltage_inv2
      slave: !secret sungrow_modbus_slave_inv2
      address: 5012 # reg 5013
      input_type: input
      count: 1
      data_type: uint16
      swap: word
      precision: 1
      unit_of_measurement: V
      device_class: Voltage
      scale: 0.1
      scan_interval: 10

    • name: MPPT2 current inv 2
      unique_id: sg_mppt2_current_inv2
      slave: !secret sungrow_modbus_slave_inv2
      address: 5013 # reg 5014
      input_type: input
      count: 1
      data_type: uint16
      swap: word
      precision: 2
      unit_of_measurement: A
      device_class: Current
      scale: 0.1
      scan_interval: 10

    • name: Total DC power inv 2
      unique_id: sg_total_dc_power_inv2
      slave: !secret sungrow_modbus_slave_inv2
      address: 5016 # reg 5017
      input_type: input
      count: 2
      data_type: uint32
      swap: word
      precision: 0
      unit_of_measurement: W
      device_class: power
      state_class: measurement
      scale: 1
      scan_interval: 10
      sensor:
      name: MPPT1_inv2 power
      unique_id: sg_mppt1_power_inv2
      unit_of_measurement: W
      device_class: power
      availability: "{{states('sensor.mppt1_voltage_inv2')|is_number and states('sensor.mppt1_current_inv2')|is_number }}"
      state: "{{ (states('sensor.mppt1_voltage_inv2') | float * states('sensor.mppt1_current_inv2') | float) |int }}"

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
Copy link

leo4417 commented Sep 8, 2023

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

@Wolkenstuermer
Copy link

Wolkenstuermer commented Sep 10, 2023

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
Copy link
Contributor

dylan09 commented Sep 10, 2023

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
Copy link

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
Copy link

howi303 commented May 1, 2024

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

@ulfben
Copy link

ulfben commented Aug 10, 2024

While waiting for the YAML-generator to be available, I attempted to automate the process of editing the modbus_sungrow.yaml to add a second inverter, using regular expressions. This was a quick and partial solution, but it might help someone avoid some manual work.

The process is as follows:

  1. Copy the original YAML file.
  2. Replace the secrets.
  3. Append 2 to every name: and _2 to every unique_id.

Since I'm on Windows, I tested this only in Notepad++, but it should still be helpful for others. :)

Step 1: copy the current modbus_sungrow.yaml and rename it to modbus_sungrow_2.yaml

Step 2: Add the IP, port, and Modbus address of inverter 2 to secrets.yaml:

sungrow_modbus_host_ip: 192.168.4.230 # master inverter
sungrow_modbus_port: 502 # Modbus port of your inverter. Default is '502'
sungrow_modbus_slave: 1 # device address of your inverter. Default is '1'

sungrow_modbus_host_ip_inv2: 192.168.4.238 # slave inverter
sungrow_modbus_port_inv2: 502
sungrow_modbus_slave_inv2: 2 #device address for the slave

Step 3: Open your newly created modbus_sungrow_2.yaml and perform a couple of search-and-replace:

Adjust the secrets:

  • sungrow_modbus_host_ip -> sungrow_modbus_host_ip_inv2
  • sungrow_modbus_port -> sungrow_modbus_port_inv2
  • sungrow_modbus_slave -> sungrow_modbus_slave_inv2

Adjust the inputs and script names:

  • set_sg_ -> set_sg_2_
  • sg_set_ -> sg_2_set_

Adjust the id's and aliases for automations:

  • - id: "automation_sungrow_global_ -> - id: "automation_sungrow_global_2_
  • - id: "automation_sungrow_inverter_ -> - id: "automation_sungrow_inverter_2_
  • alias: "sungrow inverter -> alias: "sungrow inverter 2

OR, if you prefer the terminal, you can perform all replacement in one run of sed:

sed -i 's/sungrow_modbus_host_ip\b/sungrow_modbus_host_ip_inv2/g;
        s/sungrow_modbus_port\b/sungrow_modbus_port_inv2/g;
        s/sungrow_modbus_slave\b/sungrow_modbus_slave_inv2/g;
        s/set_sg_/set_sg_2_/g;
        s/sg_set_/sg_2_set_/g;
        s/- id: "automation_sungrow_global_/- id: "automation_sungrow_global_2_/g;
        s/- id: "automation_sungrow_inverter_/- id: "automation_sungrow_inverter_2_/g;
        s/alias: "sungrow inverter/alias: "sungrow inverter 2/g' modbus_sungrow_2.yaml

Step 4: Use Regex to find and append _2 to all unique_ids:

Find What: ^\s*unique_id:.*[^_2\s]$
Replace with: $&_2

image
(You can use the "Mark" function to preview which lines will be affected.)

Step 5: Use Regex to find and append 2 to all names (this will handle comments correctly, but not quotes):

Find What: (^\s*- name:\s*)(\"[^\"]*\"|[^\r\n#]*)(\s*#.*)?$
Replace with: $1$2 2 $3

image

Step 6: Use search-and-replace to fix all quoted names with trailing 2s:

Find what: " 2
Replace with: 2 "

Save the file and check your configuration under Developer Tools. Hopefully there are no errors.

At this point you can reboot and get all the information from both inverters.

Left to do:

Ideally we should adjust all automations in the second yaml, so they adress the second inverters' sensors. Ergo, instead of (for example) 'binary_sensor.battery_charging' we need to have 'binary_sensor.battery_charging_2' throughout the file.

There are currently 52 sensors to deal with so... let me just dump them in another comment for future reference, and hopefully I or someone else will come back one day with an elegant command to handle them all in bulk. :D

Check / steal my results:

I put my edited modbus_sungrow_2.yaml in a gist for your convenience.

@ulfben
Copy link

ulfben commented Aug 11, 2024

I believe these are all the sensors referenced throughout the modbus_sungrow.yaml. To finish off our modbus_sungrow_2.yaml properly, we should append "_2" to all of these terms throughout;

binary_sensor.battery_charging
binary_sensor.battery_discharging
binary_sensor.exporting_power
binary_sensor.importing_power
binary_sensor.pv_generating
sensor.battery_capacity
sensor.battery_discharging_start_power
sensor.battery_forced_charge_discharge_cmd
sensor.battery_forced_charge_discharge_cmd_raw
sensor.battery_forced_charge_discharge_power
sensor.battery_level
sensor.battery_level_nominal
sensor.battery_max_charge_power
sensor.battery_max_discharge_power
sensor.battery_power_raw
sensor.daily_battery_charge
sensor.daily_battery_discharge
sensor.daily_exported_energy
sensor.daily_imported_energy
sensor.daily_pv_generation
sensor.ems_mode_selection
sensor.ems_mode_selection_raw
sensor.export_power_limit
sensor.export_power_limit_mode
sensor.export_power_limit_mode_raw
sensor.export_power_raw
sensor.global_mpp_scan_manual_raw 
sensor.load_power
sensor.max_soc
sensor.meter_active_power_raw
sensor.meter_phase_a_active_power_raw
sensor.meter_phase_b_active_power_raw
sensor.meter_phase_c_active_power_raw
sensor.min_soc
sensor.mppt1_current
sensor.mppt1_voltage
sensor.mppt2_current
sensor.mppt2_voltage
sensor.phase_a_voltage
sensor.phase_b_voltage
sensor.phase_c_voltage
sensor.reserved_soc_for_backup
sensor.running_state
sensor.sungrow_device_type_code
sensor.sungrow_inverter_state
sensor.system_state
sensor.total_battery_charge
sensor.total_battery_discharge
sensor.total_dc_power
sensor.total_exported_energy
sensor.total_imported_energy
sensor.total_pv_generation

If you have the Terminal addon you can use sed to achieve this. Simply navigate to the integrations directory where you have your two sungrow yaml files, and run:

sed -i 's/binary_sensor.battery_charging\b/binary_sensor.battery_charging_2/g;
        s/binary_sensor.battery_discharging\b/binary_sensor.battery_discharging_2/g;
        s/binary_sensor.exporting_power\b/binary_sensor.exporting_power_2/g;
        s/binary_sensor.importing_power\b/binary_sensor.importing_power_2/g;
        s/binary_sensor.pv_generating\b/binary_sensor.pv_generating_2/g;
        s/sensor.battery_capacity\b/sensor.battery_capacity_2/g;
        s/sensor.battery_discharging_start_power\b/sensor.battery_discharging_start_power_2/g;
        s/sensor.battery_forced_charge_discharge_cmd\b/sensor.battery_forced_charge_discharge_cmd_2/g;
        s/sensor.battery_forced_charge_discharge_cmd_raw\b/sensor.battery_forced_charge_discharge_cmd_raw_2/g;
        s/sensor.battery_forced_charge_discharge_power\b/sensor.battery_forced_charge_discharge_power_2/g;
        s/sensor.battery_level\b/sensor.battery_level_2/g;
        s/sensor.battery_level_nominal\b/sensor.battery_level_nominal_2/g;
        s/sensor.battery_max_charge_power\b/sensor.battery_max_charge_power_2/g;
	s/sensor.battery_max_discharge_power\b/sensor.battery_max_discharge_power_2/g;
        s/sensor.battery_power_raw\b/sensor.battery_power_raw_2/g;
        s/sensor.daily_battery_charge\b/sensor.daily_battery_charge_2/g;
        s/sensor.daily_battery_discharge\b/sensor.daily_battery_discharge_2/g;
        s/sensor.daily_exported_energy\b/sensor.daily_exported_energy_2/g;
        s/sensor.daily_imported_energy\b/sensor.daily_imported_energy_2/g;
        s/sensor.daily_pv_generation\b/sensor.daily_pv_generation_2/g;
        s/sensor.ems_mode_selection\b/sensor.ems_mode_selection_2/g;
        s/sensor.ems_mode_selection_raw\b/sensor.ems_mode_selection_raw_2/g;
        s/sensor.export_power_limit\b/sensor.export_power_limit_2/g;
        s/sensor.export_power_limit_mode\b/sensor.export_power_limit_mode_2/g;
        s/sensor.export_power_limit_mode_raw\b/sensor.export_power_limit_mode_raw_2/g;
        s/sensor.export_power_raw\b/sensor.export_power_raw_2/g;
        s/sensor.global_mpp_scan_manual_raw\b/sensor.global_mpp_scan_manual_raw_2/g;
        s/sensor.load_power\b/sensor.load_power_2/g;
        s/sensor.max_soc\b/sensor.max_soc_2/g;
        s/sensor.meter_active_power_raw\b/sensor.meter_active_power_raw_2/g;
        s/sensor.meter_phase_a_active_power_raw\b/sensor.meter_phase_a_active_power_raw_2/g;
        s/sensor.meter_phase_b_active_power_raw\b/sensor.meter_phase_b_active_power_raw_2/g;
        s/sensor.meter_phase_c_active_power_raw\b/sensor.meter_phase_c_active_power_raw_2/g;
        s/sensor.min_soc\b/sensor.min_soc_2/g;
        s/sensor.mppt1_current\b/sensor.mppt1_current_2/g;
        s/sensor.mppt1_voltage\b/sensor.mppt1_voltage_2/g;
        s/sensor.mppt2_current\b/sensor.mppt2_current_2/g;
        s/sensor.mppt2_voltage\b/sensor.mppt2_voltage_2/g;
        s/sensor.phase_a_voltage\b/sensor.phase_a_voltage_2/g;
        s/sensor.phase_b_voltage\b/sensor.phase_b_voltage_2/g;
        s/sensor.phase_c_voltage\b/sensor.phase_c_voltage_2/g;
        s/sensor.reserved_soc_for_backup\b/sensor.reserved_soc_for_backup_2/g;
        s/sensor.running_state\b/sensor.running_state_2/g;
        s/sensor.sungrow_device_type_code\b/sensor.sungrow_device_type_code_2/g;
        s/sensor.sungrow_inverter_state\b/sensor.sungrow_inverter_state_2/g;
        s/sensor.system_state\b/sensor.system_state_2/g;
        s/sensor.total_battery_charge\b/sensor.total_battery_charge_2/g;
        s/sensor.total_battery_discharge\b/sensor.total_battery_discharge_2/g;
        s/sensor.total_dc_power\b/sensor.total_dc_power_2/g;
        s/sensor.total_exported_energy\b/sensor.total_exported_energy_2/g;
        s/sensor.total_imported_energy\b/sensor.total_imported_energy_2/g;
        s/sensor.total_pv_generation\b/sensor.total_pv_generation_2/g' modbus_sungrow_2.yaml

Note: this will unfortunately not adjust the sensors for monthly and yearly export, as their names are concatenated in the yaml. You can edit these by hand, currently at lines 2165-2230.

@MarkusKerwath
Copy link

While waiting for the YAML-generator to be available, I attempted to automate the process of editing the modbus_sungrow.yaml to add a second inverter, using regular expressions. This was a quick and partial solution, but it might help someone avoid some manual work.

The process is as follows:

1. Copy the original YAML file.

2. Replace the secrets.

3. Append ` 2` to every name: and `_2`  to every unique_id.

Since I'm on Windows, I tested this only in Notepad++, but it should still be helpful for others. :)

Step 1: copy the current modbus_sungrow.yaml and rename it to modbus_sungrow_2.yaml

Step 2: Add the IP, port, and Modbus address of inverter 2 to secrets.yaml:

sungrow_modbus_host_ip: 192.168.4.230 # master inverter
sungrow_modbus_port: 502 # Modbus port of your inverter. Default is '502'
sungrow_modbus_slave: 1 # device address of your inverter. Default is '1'

sungrow_modbus_host_ip_inv2: 192.168.4.238 # slave inverter
sungrow_modbus_port_inv2: 502
sungrow_modbus_slave_inv2: 2 #device address for the slave

Step 3: Open your newly created modbus_sungrow_2.yaml and perform a couple of search-and-replace:

Adjust the secrets:

* `sungrow_modbus_host_ip` -> `sungrow_modbus_host_ip_inv2`

* `sungrow_modbus_port` -> `sungrow_modbus_port_inv2`

* `sungrow_modbus_slave` -> `sungrow_modbus_slave_inv2`

Adjust the inputs and script names:

* `set_sg_` -> `set_sg_2_`

* `sg_set_` -> `sg_2_set_`

Adjust the id's and aliases for automations:

* `- id: "automation_sungrow_global_` -> `- id: "automation_sungrow_global_2_`

* `- id: "automation_sungrow_inverter_` -> `- id: "automation_sungrow_inverter_2_`

* `alias: "sungrow inverter` -> `alias: "sungrow inverter 2`

OR, if you prefer the terminal, you can perform all replacement in one run of sed:

sed -i 's/sungrow_modbus_host_ip\b/sungrow_modbus_host_ip_inv2/g;
        s/sungrow_modbus_port\b/sungrow_modbus_port_inv2/g;
        s/sungrow_modbus_slave\b/sungrow_modbus_slave_inv2/g;
        s/set_sg_/set_sg_2_/g;
        s/sg_set_/sg_2_set_/g;
        s/- id: "automation_sungrow_global_/- id: "automation_sungrow_global_2_/g;
        s/- id: "automation_sungrow_inverter_/- id: "automation_sungrow_inverter_2_/g;
        s/alias: "sungrow inverter/alias: "sungrow inverter 2/g' modbus_sungrow_2.yaml

Step 4: Use Regex to find and append _2 to all unique_ids:

Find What: ^\s*unique_id:.*[^_2\s]$ Replace with: $&_2

image (You can use the "Mark" function to preview which lines will be affected.)

Step 5: Use Regex to find and append 2 to all names (this will handle comments correctly, but not quotes):

Find What: (^\s*- name:\s*)(\"[^\"]*\"|[^\r\n#]*)(\s*#.*)?$ Replace with: $1$2 2 $3

image

Step 6: Use search-and-replace to fix all quoted names with trailing 2s:

Find what: " 2 Replace with: 2 "

Save the file and check your configuration under Developer Tools. Hopefully there are no errors.

At this point you can reboot and get all the information from both inverters.

Left to do:

Ideally we should adjust all automations in the second yaml, so they adress the second inverters' sensors. Ergo, instead of (for example) 'binary_sensor.battery_charging' we need to have 'binary_sensor.battery_charging_2' throughout the file.

There are currently 52 sensors to deal with so... let me just dump them in another comment for future reference, and hopefully I or someone else will come back one day with an elegant command to handle them all in bulk. :D

Check / steal my results:

I put my edited modbus_sungrow_2.yaml on pastebin for your convenience.

Hi, can you send the eddited version again, please? Seemed Pastebin deleted it already.

Regards
Markus

@ulfben
Copy link

ulfben commented Sep 11, 2024

Absotively. I've created a gist for you. Hopefully it's allowed to stay up. :P

@MarkusKerwath
Copy link

Thank you!
hmmm
MPPT3 and MPPT4 is unavailable
Seems my slave is not accessed

@mkaiser
Copy link
Owner

mkaiser commented Sep 11, 2024

Absotively. I've created a gist for you. Hopefully it's allowed to stay up. :P

Could you maybe make a github action out of it and auto-create the file whenever the modbus_sungrow.yaml changes?

I really like having the second inverter stuff in the git, but I am afraid of the maintenance (have barely time to maintain the one file...)

@ulfben
Copy link

ulfben commented Sep 12, 2024

@mkaiser I am a complete child when it comes to git and github, but I do try to be helpful. hahaha :D

I forked your repo and tried setting up an action. Here's what I got so far.

It runs whenever a commit touches modbus_sungrow.yaml, but I've got a syntax error in one my sed-commands that I can't figure out. Here's the output from my test-run:

Run cp modbus_sungrow.yaml modbus_sungrow_2.yaml
  cp modbus_sungrow.yaml modbus_sungrow_2.yaml
  sed -i 's/sungrow_modbus_host_ip/sungrow_modbus_host_ip_inv2/g; \
  s/sungrow_modbus_port/sungrow_modbus_port_inv2/g; \
  s/sungrow_modbus_slave/sungrow_modbus_slave_inv2/g; \
  s/set_sg_/set_sg_2_/g; \
  s/sg_set_/sg_2_set_/g; \
  s/- id: "automation_sungrow_global_/- id: "automation_sungrow_global_2_/g; \
  s/- id: "automation_sungrow_inverter_/- id: "automation_sungrow_inverter_2_/g; \
  s/alias: "sungrow inverter/alias: "sungrow inverter 2/g' modbus_sungrow_2.yaml
  shell: /usr/bin/bash -e {0}
sed: -e expression #1, char 427: unterminated address regex
Error: Process completed with exit code 1.

However, when I run this block on my own terminal it works as expected. Can anyone see what I'm missing?

UPDATE: nevermind! I changed the block to invoke sed once for each edit instead of trying to do all edits in one go, and now it all works. Just need to figure out how to place the generated file in the repo?

@ulfben
Copy link

ulfben commented Sep 12, 2024

Could you maybe make a github action out of it and auto-create the file whenever the modbus_sungrow.yaml changes

Yes! I've set it up in a fork over here. I know nothing about git so... just do what you need to copy .github/workflows/ back to your repo and you should be off to the races.

Remaining work: this action does not yet adjust the sensors for monthly and yearly export, as their names are concatenated in the yaml (currently at lines 2165-2230) and I don't know the yaml (or python?) syntax well enough to touch any of that.

If somebody could come up with a good line of sed to touch those up, that would be great. :)

@mkaiser
Copy link
Owner

mkaiser commented Sep 21, 2024

I am a complete child when it comes to git and github,

well, you have grown fast :)

Thanks a lot I just merged it (but the file has an "experimental" in its name. I do not have any time to look at this:

Remaining work: this action does not yet adjust the sensors for monthly and yearly export, as their names are concatenated in the yaml (currently at lines 2165-2230) and I don't know the yaml (or python?) syntax well enough to touch any of that.

... maybe someone will fix it :)

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests