kellerza / sunsynk

Deye/Sunsynk Inverter Python library and Home Assistant OS Addon
https://kellerza.github.io/sunsynk/
MIT License
209 stars 88 forks source link

Compatibility with Sunsynk 12kw 3-phase inverter? #63

Closed lubster85 closed 1 year ago

lubster85 commented 2 years ago

Hi there

I recently had a Sunsynk 12kw 3-phase inverter installed, but I'm a little unsure if this integration works with this model. I purchased a USB-RS485 cable from Solar-Assistant (https://solar-assistant.io/shop/products/sunsynk_rs485) and tried starting up the integration.

I've tried a few ports on the inverter with no success yet, but I was hoping to sense-check myself here as I don't recall the 3-phase inverter being included in the list of tested inverters.

IMG_1743

My understanding is that the "Meter-485" port could be used for monitoring and also the "BMS" port.

Referencing Solar Assistant, they claim there was a firmware change recently.

The inverter manufacturer released a firmware update which changed the port to read the inverter via RS485. An RJ45 splitter can be used to allow SolarAssistant to read the inverter while the inverter is also reading a battery via CAN.

Is there perhaps something else I may be missing or should try? If not, I'll try find a splitter and confirm if that makes a difference.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
2022-09-24 08:45:31,191 INFO    Loading HASS OS configuration
2022-09-24 08:45:31,264 INFO    Filter *last used for battery_soc, total_battery_charge, total_battery_discharge, total_grid_export, total_grid_import, total_pv_power
2022-09-24 08:45:31,273 INFO    Protocol made connection.
2022-09-24 08:45:31,274 INFO    Connected to /dev/ttyUSB0
2022-09-24 08:45:41,286 ERROR   Timeout reading: 
2022-09-24 08:45:41,287 INFO    ############################################################
2022-09-24 08:45:41,287 INFO    No response on the Modbus interface, try checking the wiring to the Inverter, the USB-to-RS485 converter, etc
2022-09-24 08:45:41,287 INFO    ############################################################
2022-09-24 08:45:41,288 CRITICAL This Add-On will terminate in 30 seconds, use the Supervisor Watchdog to restart automatically.
[cmd] ./run.py exited 0
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
kellerza commented 2 years ago

I have no idea if this will work, have not seen any document on how to wire up the RS485 on the 12kw unit. There might even be different registers (to measure power etc on different phases etc). Would be great if you can test and report back

lubster85 commented 2 years ago

Will certainly do so. I've ordered a splitter as I think that one "BMS" port is the one needed for communication. Out of interest, I've seen elsewhere that when communicating over modbus, not to use Modbus SN id "00". Our inverter is configured with 00. What is the issue with using 0 as opposed to something like 1?

Yesterday I tried changing this through the Sunsynk app and shortly afterwards there was an error event with audible alert: F13: Grid_Mode_changed. I was a little taken back and changed it back to 0. Do you know if a change like this be a "real" error or is that normal behaviour for the inverter to log an event like this?

cods4 commented 2 years ago

Will certainly do so. I've ordered a splitter as I think that one "BMS" port is the one needed for communication. Out of interest, I've seen elsewhere that when communicating over modbus, not to use Modbus SN id "00". Our inverter is configured with 00. What is the issue with using 0 as opposed to something like 1?

Yesterday I tried changing this through the Sunsynk app and shortly afterwards there was an error event with audible alert: F13: Grid_Mode_changed. I was a little taken back and changed it back to 0. Do you know if a change like this be a "real" error or is that normal behaviour for the inverter to log an event like this?

As long as the the parallel box isn't checked (you only have the one inverter right?), Changing the Modbus SN ID to 01 wont cause any problems. The F13 error will clear after a few minutes and the inverter output will turn back on.

kellerza commented 2 years ago

If you have multiple inverters installed, or parallel checked, it's highly unlikely that your Modbus SN is till 0!

Modbus address 0 is a broadcast address and you are not allowed to respond to any message you receive on 0. With older firmware versions the inverter always responded...

lubster85 commented 2 years ago

Thank you @kellerza and @cods4. Yes, only 1 x 3-phase inverter. Will report back one I have some more info.

sebmueller commented 2 years ago

I have the same problem with a Deye 12kw Inverter. Solar Assistant reads it out, but this plugin with homeassistant doesnt read.

The only one is the Serial No.

Do you have an idea?

ronaldt80 commented 2 years ago

Planning to buy the same inverter (3fase/12kw) combined with batteries only (no solar) so very curious to hear about your progress.

Out of curiosity, with this add-on, is it possible to instruct the inverter (for instance to change discharge or charge from grid settings) or is the addon reporting state sensors only?

cods4 commented 2 years ago

I have the same problem with a Deye 12kw Inverter. Solar Assistant reads it out, but this plugin with homeassistant doesnt read.

The only one is the Serial No.

Do you have an idea?

The fact that it's displaying the SN means it is communicating, so that's a good start.

Have you entered the inverter SN into the config? If so, try remove the quotation marks around the serial number.

sebmueller commented 2 years ago

Hi, thanks for the fast reply!

in the meanwhile, i figured out, what is the actual problem!

The Deye Sun-12k-SG04LP3 seems to "speak" another protocol.

Last night, I found another protocol description with different register addresses than the "other" one, you are using in your add on.

I tried a NodeRed Flow to read out the inverter, it worked!

I attach both documents, the old and the new one.

sunsynk_modbus - no chinese.docx Modbus Deye amit posun.docx

found here, a german forum: https://www.photovoltaikforum.com/thread/169125-answer-everything-about-deye-inverters/?pageNo=64

The Serial# registers are equal, also the Register: 02 - Communication Protocol Version. When I read this, I get a 0x0104. What version do you get?

Maybe, it is possible to implement both version of the protocol, switching after the read of the protocol version.

lubster85 commented 2 years ago

I'm not sure if the same port issue exists with the 3-phase Sunsynk and Deye, but I think the port could also be the issue here. I'm waiting on a delivery for a splitter and hope to test on the "BMS" port soon.

Interestingly I also managed to connect with the inverter using NodeRed (Using "Meter-485" port) and managed to pull some values out of it --- however the values appeared not to change over time.

As soon as I have the splitter, my plan is to first test with this integration "out the box" and see what I get. Else I'll play around more with NodeRed.

kellerza commented 2 years ago

@sebmueller thanks for the document. This document shows a new device type-which seems to be the 3ph inverter. So far we’ve tested the dev type 0x0300, while the 3ph is 0x0500.

The key would be to go through the new doc and map the register numbers that you are interested in. My guess is that the current implementation will either give you total(across phases) or only one of the phases, or worst case the single-phase registers will give you something entirely different.

Once we have the registers of the 3phase inverter it is possible to choose either based on the value of the device type

@sebmueller how did you connect to you inverter? (Might help @lubster85)

@ronaldt80 you can read and you can write RW type sensors.

definitions.py will show you the registers and which are read &write — use the dev version of the addon for write

lubster85 commented 2 years ago

I've started having a look at the doc and I can confirm that I'm getting readings that appear to be correct. I'm still going through them to work out which is which.

ronaldt80 commented 2 years ago

Keen to hear about your experience @lubster85 and @sebmueller - my sunsynk 3ph 12kw has been ordered. I intend to switch to dynamic energy tariffs with the aim to buy low sell high :) - typically the pricing curve shows 2 peaks and 2 troughs so plenty of options to recover part of the investment. Key is however to also steer the export / import settings of the inverter - hope the r/w settings permit this

lubster85 commented 2 years ago

I've been playing around using NodeRed for now. Thank you @sebmueller for sharing that doc. I think the following "translations" are accurate:

Label Single-phase address 3-Phase address
Grid_Import_day 76 520
Grid_Export_Day 77 521
Grid_Inverter_Voltage 154  
Grid_Grid_Voltage 150  
Total_Load 178 653
Grid_Inverter_Load 167 608
Grid_Grid_CT 172 607
Battery_Volts 183 587
Battery_SoC 184 588  
Battery_Output_Power 190 590
Battery_Output_Current 191 591
Overall_State 59  
Battery_Charge_Day 70 514
Battery_Discharge_Day 71 515
Battery_Charge_Volts 312 606
Grid_Grid_Frequency 79 183
Temperature Battery 182 586
Temperature Environment 95 541
Temperature DC Transformer 90 540
Temperature Radiator 91 541
Inverter_total_power 175 636
DayActive PowerWh 60 77
DayReactive_PowerWh 61 78

When I have some more time I'll look at this in more detail, but hope this helps for now. I'm super-happy that I'm at least able to pull in some data into home assistant now.

image
sebmueller commented 2 years ago

@lubster85 you are welcome. would you also share your nodered flow?

For Overall_State - you can use register 500 (run state)

0000 待机 standby 0001 自检 selfcheck 0002 ↓常 normal 0003 告警 alarm 0004 故障 fault

image

Here is my nodered flow: 3ph-inverter.zip

image

@kellerza is it possible to extent your implementation to read out also the 3ph inverter?

kellerza commented 2 years ago

Nice work @lubster85 ! Not sure exactly when I'll get to it but it is possible to add a second set of registers by extending the base sensor class.

SimonF89 commented 2 years ago

@kellerza when do you think you will add the Deye 12kw? Depending on this, i would deside if i order the solar assistant or if i would use the home assistant :)

lubster85 commented 2 years ago

@sebmueller i will definitely share, not a problem. Just hoping to add some of the “3-phase” metrics first and will share.

Out of interest - I used a splitter on the “BMS” port to split readings from the inverter (based on the solar-assistant site suggestion). I have a sneaky suspicion that this was not necessary in my case (I was just referencing the incorrect registers initially).

Would be interesting to hear how others have connected.

jcwilson01 commented 2 years ago

@lubster85 If I am understanding it correctly, you only managed to start getting readings once you started using Node-Red? You didn't have any success using @kellerza add-on? I'm completely new to all of this and I'm also trying to get readings out of the 12kW Sunsynk without much success. I just assumed I was doing something wrong as I was getting the same error in the logs as you initially did, but I will try Node-Red and see what happens. Maybe I'm completely off-base here, but shouldn't we get something (even incorrect or 'zero' readings out of the add-on, even if the registers are different? Or did you start getting some sort of readings from the inverter when you swapped the Modbus SN to 01? I also managed to shut my inverter down by changing the SN to 01. Nearly had heart failure. But, after doing further reading, apparently you are supposed to isolate all loads from the inverter before changing anything on that settings page. Live and Learn.

sebmueller commented 1 year ago

@lubster85 I just used the Modbus Port. But I also read, it depends on the firmware version, which port es usable. In the future, I want to connect my diy battery, but therefore I need a converter for the battery informations.

lubster85 commented 1 year ago

@jcwilson01, correct. This is because the integration developed by @kellerza was made-for and tested on the inverters listed here: https://github.com/kellerza/sunsynk#tested-inverters. Interestingly enough, when I changed the modbus serial id to '01', the integration picked up my inverter serial number as it started.

I'm really no expert and I haven't looked under the hood of what this integration is doing, but I think the integration is looking for an expected response, not getting it, and safely stopping itself. If you look at the two docs that @sebmueller shared a few posts above, you'll see just how different the two are. I'm still going through it all and double-checking my initial "mappings". Once I'm done I'll share my flows (to be used at your own risk). :-)

lubster85 commented 1 year ago

Updated addresses for 3-phase inverter "monitoring" values.

Name 3-Phase address
Battery_Charge_Day 514
Battery_Charge_Volts 606
Battery_Discharge_Day 515
Battery_Output_Current 591
Battery_Output_Power 590
Battery_SoC 588
Battery_Volts 587
DayActive PowerWh 501
DayReactive_PowerWh 502
Grid_Export_Day 521
Grid_Grid_CT 607
Grid_Grid_Frequency 183
Grid_Import_day 520
Grid_Inverter_Load 619
Grid_Phase_Voltage_A 598
Grid_Phase_Voltage_B 599
Grid_Phase_Voltage_C 600
Inverter_Phase_Voltage_A 627
Inverter_Phase_Voltage_B 628
Inverter_Phase_Voltage_C 629
Inverter_total_power 636
Run_State 500
Solar_PV_Day 529
Solar_PV1_Amps 677
Solar_PV1_Voltage 676
Solar_PV2_Amps 679
Solar_PV2_Voltage 678
Temperature Battery 586
Temperature DC Transformer 540
Temperature Environment ?
Temperature Heat Sink 541
Total_Load 653
Total_Load_Phase_A 650
Total_Load_Phase_B 651
Total_Load_Phase_C 652

Then these are some of the "settings" addresses I can find. Most of these are R/W addresses (i.e. you can also write back to the inverter - use with caution :-) ).

Name Address
Read_Time_Z1 148
Read_Time_Z2 149
Read_Time_Z3 150
Read_Time_Z4 151
Read_Time_Z5 152
Read_Time_Z6 153
Read_SoC_Z1 166
Read_SoC_Z2 167
Read_SoC_Z3 168
Read_SoC_Z4 169
Read_SoC_Z5 170
Read_SoC_Z6 171
Read_GC_Z1 172
Read_GC_Z2 173
Read_GC_Z3 174
Read_GC_Z4 175
Read_GC_Z5 176
Read_GC_Z6 177
Read_PL 141
Read_UseTimer 146
Read_SolarExport 145
Read_LoadLimit 142
Read_BatShut 115
Read_BatLow 117
Read_BatRestart 116
Read_BatMaxC 108
Read_BatMaxDC 109
Read_GridEn 130
Read_GridC 128
Read_ExportLimit 143
Read_SM_Z1 (Sell mode time point 1) 154
Read_SM_Z2 (Sell mode time point 2) 155
Read_SM_Z3 (Sell mode time point 3) 156
Read_SM_Z4 (Sell mode time point 4) 157
Read_SM_Z5 (Sell mode time point 5) 158
Read_SM_Z6 (Sell mode time point 6) 159
ronaldt80 commented 1 year ago

The way i read the manual 148 - 177 should al be read/write:

148- 153 accepts a time value, where 1745 would equate to quarter to 6.

154 - 159 should be the max watt power importing or exporting, 8000 being 8kw

160 - 165 is the voltage

166 - 171 is the target SoC level

172 - 177 is enable/disable of charge mode

Unfortunately I will only receive my deye in december.. so no possibility to test

lubster85 commented 1 year ago

@sebmueller see attached "my" NodeRed flow. I found this at this forum post and adapted it to suit my needs. Much of what I have done is stripped some functionality I didn't need/understand and I also added some of the 3-phase metrics in (as referenced in the posts above). Still very much a work in progress so please treat it with caution. :-P flows (Sunsynk-3ph-MQTT).json.zip

@kellerza thank you for the quick replies and apologies - you'll see the references I've posted above are based on the NodeRed flow I found (and not in line with your definitions.py) naming. Nonetheless I hope it proves helpful if/when you consider looking at this.

In the meantime, I thought I'd share some of the Home Assistant (apexcharts) charts I've put together for our setup :-) We've been away from home so the usage is lower than normal, but its been particularly interesting seeing the usage by phase. It looks like most of our plugs + lights are on Phase A, pool pump and some other things on B and the Stove/Oven on C.

image

sebmueller commented 1 year ago

@lubster85 thanks for sharing your flows! :) could you also share your HA charts?

@kellerza are there some news about integrating a second set of registers in your addon?

kind regards

lubster85 commented 1 year ago

@lubster85 thanks for sharing your flows! :) could you also share your HA charts?

No problem - you'll see there are a few custom cards and a theme that you'll need to download/change. I'm sure it's also not perfect, but its getting there :-)

views:
  - title: Inverter
    path: inverter
    theme: Mushroom
    badges: []
    cards:
      - type: vertical-stack
        cards:
          - type: custom:mushroom-title-card
            title: Energy Summary
          - square: false
            columns: 2
            type: grid
            cards:
              - type: custom:mushroom-entity-card
                name: PV
                entity: sensor.sunsynk_solar_total_power
                icon_color: '#FCCA1B'
                icon: mdi:solar-power-variant
              - type: custom:mushroom-entity-card
                name: Load
                entity: sensor.sunsynk_total_load
                icon_color: '#F78F24'
                fill_container: false
                icon: mdi:power-plug
              - type: custom:mushroom-entity-card
                name: Battery
                entity: sensor.sunsynk_battery_output_power
                icon_color: '#0B84B3'
                icon: mdi:battery-charging-100
              - type: custom:mushroom-entity-card
                name: Grid
                entity: sensor.sunsynk_grid_ct
                icon_color: '#EA285B'
                icon: mdi:transmission-tower-export
              - type: custom:mushroom-entity-card
                name: Battery
                entity: sensor.sunsynk_battery_soc
                icon_color: '#1D8D7D'
          - type: custom:apexcharts-card
            header:
              title: Overview
              show: false
              show_states: false
              colorize_states: true
            all_series_config:
              stroke_width: 2
              opacity: 0.3
              type: area
            color_list:
              - F78F24
              - 0B84B3
              - EA285B
              - FCCA1B
              - 1D8D7D
              - F39089
              - '274656'
              - 0ECAEE
              - 2BCDBC
            apex_config:
              chart:
                height: 350
                zoom:
                  type: x
                  enabled: true
                  autoScaleYaxis: true
                dropshadow:
                  enabled: false
                toolbar:
                  show: true
                  autoSelected: zoom
                xaxis.type: datetime
              stroke:
                width: 1
                curve: smooth
                opacity: 1
            yaxis:
              - id: first
                max: 100
                min: -100
                decimals: 0
                apex_config:
                  tickAmount: 4
              - id: second
                opposite: true
                decimals: 0
                apex_config:
                  tickAmount: 4
            series:
              - entity: sensor.sunsynk_total_load
                name: Tolal load
                group_by:
                  func: avg
                  duration: 10min
                yaxis_id: second
                type: area
                opacity: 0.3
              - entity: sensor.sunsynk_battery_output_power
                name: Battery output
                invert: true
                group_by:
                  func: avg
                  duration: 10min
                yaxis_id: second
                type: area
                opacity: 0.3
              - entity: sensor.sunsynk_grid_load_calc
                name: Grid
                group_by:
                  func: avg
                  duration: 10min
                yaxis_id: second
                type: area
                opacity: 0.3
              - entity: sensor.sunsynk_solar_pv1_power
                name: PV
                group_by:
                  func: avg
                  duration: 10min
                yaxis_id: second
                type: area
                opacity: 0.3
              - entity: sensor.sunsynk_battery_soc
                name: Battery %
                group_by:
                  func: avg
                  duration: 10min
                yaxis_id: first
                type: line
                opacity: 1
      - type: vertical-stack
        cards:
          - type: custom:mushroom-title-card
            title: Solar production
          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.sunsynk_solar_total_power
                max: 4550
                name: Solar power
                unit: W
                theme: Mushroom
                needle: true
                segments:
                  - from: 0
                    color: '#FCCA1B'
              - type: vertical-stack
                cards:
                  - type: custom:mushroom-entity-card
                    name: PV today
                    entity: sensor.sunsynk_solar_pv_day
                    icon_color: '#FCCA1B'
                    icon: mdi:solar-power-variant
                    fill_container: false
                  - type: custom:mushroom-entity-card
                    name: Green energy use
                    entity: sensor.co2_signal_grid_fossil_fuel_percentage
                    icon_color: '#1D8D7D'
                    icon: mdi:leaf-circle
          - type: custom:apexcharts-card
            header:
              title: Overview
              show: false
              show_states: false
              colorize_states: true
            all_series_config:
              stroke_width: 2
              opacity: 0.3
              type: area
            color_list:
              - FCCA1B
              - 0B84B3
              - F78F24
              - EA285B
              - 1D8D7D
              - F39089
              - '274656'
              - 0ECAEE
              - 2BCDBC
            apex_config:
              chart:
                height: 350
                zoom:
                  type: x
                  enabled: true
                  autoScaleYaxis: true
                dropshadow:
                  enabled: false
                toolbar:
                  show: false
                  autoSelected: zoom
                xaxis.type: datetime
              stroke:
                width: 2
                curve: smooth
                opacity: 1
            yaxis:
              - id: first
                max: 100
                min: -100
                decimals: 0
                apex_config:
                  tickAmount: 4
              - id: second
                opposite: true
                decimals: 0
                apex_config:
                  tickAmount: 4
            series:
              - entity: sensor.sunsynk_solar_total_power
                name: Solar production
                group_by:
                  func: avg
                  duration: 10min
                yaxis_id: second
                type: area
                opacity: 0.3
              - entity: sensor.power_production_now
                name: Estimate
                stroke_width: 5
                invert: false
                group_by:
                  func: avg
                  duration: 15min
                yaxis_id: second
                type: line
                opacity: 1
      - type: vertical-stack
        cards:
          - type: custom:mushroom-title-card
            title: Load
          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.sunsynk_total_load
                max: 4000
                name: Total load
                unit: W
                theme: Mushroom
                needle: true
                segments:
                  - from: 0
                    color: '#F78F24'
              - type: gauge
                entity: sensor.sunsynk_total_load_phase_a
                max: 4000
                name: Phase A
                unit: W
                theme: Mushroom
                needle: true
                segments:
                  - from: 0
                    color: '#EA285B'
          - type: horizontal-stack
            cards:
              - type: gauge
                entity: sensor.sunsynk_total_load_phase_b
                max: 4000
                name: Phase B
                unit: W
                theme: Mushroom
                needle: true
                segments:
                  - from: 0
                    color: '#FCCA1B'
              - type: gauge
                entity: sensor.sunsynk_total_load_phase_c
                max: 4000
                name: Phase C
                unit: W
                theme: Mushroom
                needle: true
                segments:
                  - from: 0
                    color: '#0B84B3'
          - type: custom:apexcharts-card
            graph_span: 24h
            update_interval: 5m
            stacked: true
            header:
              title: Load by phase
              show: false
              show_states: true
              colorize_states: true
            color_list:
              - EA285B
              - FCCA1B
              - 0B84B3
              - 1D8D7D
              - F78F24
              - F39089
              - '274656'
              - 0ECAEE
              - 2BCDBC
            apex_config:
              chart:
                height: 350
                zoom:
                  type: x
                  enabled: true
                  autoScaleYaxis: true
                dropshadow:
                  enabled: false
                toolbar:
                  show: false
                  autoSelected: zoom
                xaxis.type: datetime
              stroke:
                width: 2
                curve: smooth
                opacity: 1
            series:
              - entity: sensor.sunsynk_total_load_phase_a
                name: Phase A
                group_by:
                  func: avg
                  duration: 5min
                yaxis_id: first
                opacity: 1
                type: area
              - entity: sensor.sunsynk_total_load_phase_b
                name: Phase B
                group_by:
                  func: avg
                  duration: 5min
                yaxis_id: first
                opacity: 1
                type: area
              - entity: sensor.sunsynk_total_load_phase_c
                name: Phase C
                group_by:
                  func: avg
                  duration: 5min
                yaxis_id: first
                opacity: 1
                type: area
      - type: vertical-stack
        cards:
          - type: custom:mushroom-title-card
            title: Batteries
          - square: false
            columns: 2
            type: grid
            cards: []
          - type: gauge
            entity: sensor.sunsynk_battery_output_power
            max: 2000
            name: Battery (output)
            unit: W
            theme: Mushroom
            needle: true
            min: -2000
            segments:
              - from: -2000
                color: '#EA285B'
              - from: 0
                color: '#0B84B3'
          - type: custom:apexcharts-card
            header:
              title: Overview
              show: false
              show_states: false
              colorize_states: true
            all_series_config:
              stroke_width: 2
              opacity: 0.3
              type: area
            color_list:
              - 0B84B3
              - 1D8D7D
              - F78F24
              - EA285B
              - FCCA1B
              - F39089
              - '274656'
              - 0ECAEE
              - 2BCDBC
            apex_config:
              chart:
                height: 350
                zoom:
                  type: x
                  enabled: true
                  autoScaleYaxis: true
                dropshadow:
                  enabled: false
                toolbar:
                  show: true
                  autoSelected: zoom
                xaxis.type: datetime
              stroke:
                width: 1
                curve: smooth
                opacity: 1
            yaxis:
              - id: first
                decimals: 0
                apex_config:
                  tickAmount: 4
                min: 0
                max: 100
              - id: second
                opposite: true
                decimals: 0
                apex_config:
                  tickAmount: 4
                min: -2000
                max: 2000
            series:
              - entity: sensor.sunsynk_battery_output_power
                name: Battery output
                invert: true
                group_by:
                  func: avg
                  duration: 10min
                yaxis_id: second
                type: column
                opacity: 1
              - entity: sensor.sunsynk_battery_soc
                name: Battery %
                group_by:
                  func: avg
                  duration: 60min
                yaxis_id: first
                type: line
                opacity: 1
sebmueller commented 1 year ago

@lubster85 I played around with my inverter, wondering why grid_inverter_load is still 0. I think, the register 619 is the correct one, reading the current grid load. could you have a look at your readings?

sebmueller commented 1 year ago

@lubster85 InverterState.json.txt

I also figured out, that the Overall State decoding in you flow was buggy. Please try this one

sebmueller commented 1 year ago

@lubster85

thanks for sharing your dashboard, looks nice :)

image

sebmueller commented 1 year ago

@lubster85 I found m

Register 606, in the Flow it is used for "battery_charge_volts", this is in the "old / other" protocol. in the new one, 606 is "C phase power on the inner side of the grid" but I am not sure, what the values mean.

lubster85 commented 1 year ago

@lubster85 I played around with my inverter, wondering why grid_inverter_load is still 0. I think, the register 619 is the correct one, reading the current grid load. could you have a look at your readings?

Thank you, this looks right now. Mine was also pulling in 0

lubster85 commented 1 year ago

@lubster85 I found m

Register 606, in the Flow it is used for "battery_charge_volts", this is in the "old / other" protocol. in the new one, 606 is "C phase power on the inner side of the grid" but I am not sure, what the values mean.

Thanks for that too - what about 210?

sebmueller commented 1 year ago

@lubster85 : Reg 210, I get only '0'.

another question, was you able to write a register in the inverter? I tried, but I was not successfull.

lubster85 commented 1 year ago

@lubster85 : Reg 210, I get only '0'.

another question, was you able to write a register in the inverter? I tried, but I was not successfull.

Apologies @sebmueller for not replying. I somehow missed this. Initially I also thought I was not able to write back to the inverter (my initial test was to change something like the time by + 1). But it looks like values in 5 minute increments work OK.

It's also worth noting that it takes a few seconds to "read" the current values. But I've definitely been able to write back settings now. Below are my current times that I've set.

image

NismoBoy34 commented 1 year ago

Thanks for the digging work carried out so far . Have managed to get a copy working directly from node red first time attempt so my abilities are abit Limited.. soc was reporting the wrong value changed It to 588 I think and we got the right info . I'm in the process of trying to create some automation in nodered but fetching and using the soc value from home assistant which doesn't seem to work . Get a red square below the node with a statement not found. I am using the entity id deye battery soc from the drop down list. Will keep tinkering but happy to contribute with more values and findings to get this project moving forward

NismoBoy34 commented 1 year ago

got it working just needed to add some form of delays, The next issue is debug in node red seems to show communication drop outs randomly must be a timing issue on the 485 image

brendanvz commented 1 year ago

I found the following when downloading the operation data for my plant from https://www.sunsynk.net/workdata/list The excel column headers were suffixed with what looks like an address. Hope it's useful.

name address
chargeVolt(V) 210
dischargeVolt(V) 211
chargeCurrentLimit(A) 212
dischargeCurrentLimit(A) 213
realtimeCap(%) 214
realtimeVolt(V) 215
realtimeCurrent(A) 216
realtimeTemp(℃) 217
runStatus(NA) 500
netoday(kWh) 502
htoday(S) 503
netotal(kWh) 506-507
batChargeToday(kWh) 514
batDischargeToday(kWh) 515
batChargeTotal(kWh) 516-517
batDischargeTotal(kWh) 518-519
gridBuyToday(kWh) 520
gridSellToday(kWh) 521
gridBuyTotal(kWh) 522-523
gridSellTotal(kWh) 524-525
dailyUsed(kWh) 526
totalUsed(kWh) 527-528
pvEtoday(kWh) 529
todayPv1(kWh) 530
todayPv2(kWh) 531
todayPv3(kWh) 532
todayPv4(kWh) 533
pvHistory(kWh) 534-535
genToday(kWh) 536
genTotal(kWh) 537-538
genDailyTime(h) 539
dcTemp(℃) 540
heatSinkTemp(℃) 541
acRelayStatus(NA) 552
batteryTemp(℃) 586
batteryVolt(V) 587
batteryEnergy(%) 588
batteryPower(W) 590
batteryCurrent(A) 591
correctedEnergy(Ah) 592
vac1(V) 598
vac2(V) 599
vac3(V) 600
aLineVolt(V) 601
bLineVolt(V) 602
cLineVolt(V) 603
aInsidePower(W) 604
bInsidePower(W) 605
cInsidePower(W) 606
gridInsideTotalPac(W) 607
gridInsideTotalSac(VA) 608
gridFac(Hz) 609
iac1(A) 610
iac2(A) 611
iac3(A) 612
aOutsideCurrent(A) 613
bOutsideCurrent(A) 614
cOutsideCurrent(A) 615
aOutsidePower(W) 616
bOutsidePower(W) 617
cOutsidePower(W) 618
gridOutsideTotalPac(W) 619
gridOutsideTotalSac(VA) 620
pf(NA) 621
aPower(W) 622
bPower(W) 623
cPower(W) 624
gridTotalPac(W) 625
invAVolt(V) 627
invBVolt(V) 628
invCVolt(V) 629
invACurrent(A) 630
invBCurrent(A) 631
invCCurrent(A) 632
invAPower(W) 633
invBPower(W) 634
invCPower(W) 635
invTotalPower(W) 636
invTotalSac(VA) 637
invFac(Hz) 638
upsLoadAPower(W) 640
upsLoadBPower(W) 641
upsLoadCPower(W) 642
upsLoadTotalPower(W) 643
loadAVolt(V) 644
loadBVolt(V) 645
loadCVolt(V) 646
loadAPower(W) 650
loadBPower(W) 651
loadCPower(W) 652
loadTotalPac(W) 653
loadTotalSac(VA) 654
genAVolt(V) 661
genBVolt(V) 662
genCVolt(V) 663
genAPower(W) 664
genBPower(W) 665
genCPower(W) 666
genTotalPower(W) 667
ppv1(W) 672
ppv2(W) 673
ppv3(W) 674
ppv4(W) 675
vpv1(V) 676
ipv1(A) 677
vpv2(V) 678
ipv2(A) 679
vpv3(V) 680
ipv3(A) 681
vpv4(V) 682
ipv4(A) 683
lubster85 commented 1 year ago

@brendanvz this is incredibly helpful, thanks.

Does anyone know what the difference between "inside" and "outside" power is when looking at metrics like aOutsidePower (616) vs aInsidePower (604)?

TheKamakaZi commented 1 year ago

@lubster85, From the looks of things in my testing Outside applies to exporting to grid, and Inside to importing from grid.

I may be wrong. I'm still trying to figure out some oddness in my numbers when the battery's pulling or pushing high current.

NismoBoy34 commented 1 year ago

for the record ive managed to get my readings fairly accurate with the above flows and no time outs now to work out what the settings read and write are any pointers so i can start to contribute ?

kababoom commented 1 year ago

Anyone working on an adjusted definitions.py for a 3phase model?

The node-red flow looks awesome too but don't think it will work in the ha-node-red (at least not in mine),

sebmueller commented 1 year ago

@kababoom: in my ha-node-red the flow is working well. Whats not working in your node-red?

kababoom commented 1 year ago

@sebmueller I did import on a new flow and got 'gate' and 'cycle' not found hence could not deploy and assumed it was non-ha version.

kellerza commented 1 year ago

If there is someone willing to build a definitions.py / definitions12k.py for the 12kW we can easily integrate it,- I can add code to select between the two.

The first step would be to edits the definitions.py and to test it locally on their inverter - it should be easy to do with copy2local.cmd

kababoom commented 1 year ago

@kellerza I got the 8kW version SUN-8K-SG04LP3 but assume the registers to be the same as the 12kW. I'm, mostly interested in setting the 'time of use' schedule (6 lines with time, charge, power, voltage/percentage). So I don't have walk 'al the way' to the garage. Oh and also because the menu is weird, setup and operation are mixed, you need to go through 'dangerous' setup items to the operating settings.

So it's adjusting, run cmd (perhaps skip some lines), restart the add-on, check log?

kellerza commented 1 year ago

with a handle that includes boom! you should not assume too much, but in this case you should be covered:

https://github.com/kellerza/sunsynk#tested-inverters

You can set power, charge and time today (no voltages!)

kababoom commented 1 year ago

@kellerza that's the 1phase version, again assuming ;-) Mine looks 100% like the picture from topic starter.

Will start with reading, does that also require a boomswitch?

Edit: My 8kW 3phase getting proper values from the 12kW 3phase addresses shared by others...

<!DOCTYPE html>

Name 3-Phase address read value
Battery_SoC 588 15
Battery_Volts 587 52.00
Run_State 500 2
Temperature Battery 586 11.30 (winter here)
Inverter_Phase_Voltage_A 627 225.8
Inverter_Phase_Voltage_B 628 229.5
Inverter_Phase_Voltage_C 629 230.6
Read_SM_Z1 154 2000

Installing the addon locally gives python3 not found for some reason. Tbc.

kellerza commented 1 year ago

To install an addon on you local hass server: copy all the relevant files to you shared /addon folder (use the samba addon to share this)

the copy2local.cmd script copies all the required files

the you can go to the addon store, refresh it and you should have a local sunsynk addon. Once installed, you simply run copy2local and the Rebuils the addon

kababoom commented 1 year ago

@kellerza Thank you for your help.

Done exactly that including installing unix-utils for windows to support cp + sed the cmd needs but the sed -i is not working correctly. Tried different quotes got rid of an error message but dockerfile is not created.

Will look for another sed version or create the dockerfile otherwise.

GNU sed version 4.2.1 Copyright (C) 2009 Free Software Foundation, Inc.

Edit: sed (GNU sed) 4.9 from CygWin is working.

Edit2: but still get the error

[s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done. env: can't execute 'python3 ': No such file or directory [cmd] ./run.py exited 127 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal.

kellerza commented 1 year ago

Try msys2 for all these unix shell tools.

And you cannot go wrong with Vscode for editing.