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

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

Closed
lubster85 opened this issue Sep 25, 2022 · 81 comments
Closed

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

lubster85 opened this issue Sep 25, 2022 · 81 comments

Comments

@lubster85
Copy link

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

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

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

cods4 commented Sep 27, 2022

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

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

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

@sebmueller
Copy link

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

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

cods4 commented Sep 28, 2022

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

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

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

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

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

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

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

sebmueller commented Sep 30, 2022

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

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

SimonF89 commented Oct 2, 2022

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

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

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

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

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

lubster85 commented Oct 5, 2022

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

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

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

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

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

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

@lubster85
InverterState.json.txt

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

@sebmueller
Copy link

@lubster85

thanks for sharing your dashboard, looks nice :)

image

@sebmueller
Copy link

@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.

@archi
Copy link

archi commented Jan 27, 2023

I use this Modbus Gateway. But USB should work as well, though I didn't try that.

@kababoom
Copy link
Contributor

kababoom commented Jan 28, 2023

@archi Was able to debug with USB connected to my MBPro but have ordered the Wave tcp gateway anyway. Bit chilly in the garage...

Have added the system program settings and have tested the write functionality (simple time change), which seems to work just fine. I'm not sure about the 'Prog mode' options though, is that 1phase specific? or firmware specific, I'm still on C027 waiting for an update.
Mine just got the general 'Time of use' checkbox and:
Grid charge - Gen charge - Time from - Time to - Power - Voltage/Soc%

There are still some unknown registers and not yet translated ones, I have reused your comment: # 12k??

Todo: test and add the following as RW
Export limit 143
Bat max charge 108
Bat max discharge 109
Use timer 146

Also noticed, although in several lists, anything in 200 range returns 0 from my inverter.

Here's a link to the definitions file, when I've sorted more I will send pull.
https://github.com/kababoom/sunsynk/blob/main/sunsynk/definitions.py

Here's a list of the sensors and the one skipped:

- battery_soc
- battery_voltage
- battery_power
- battery_current
- inverter_power
- inverter_l1_power
- inverter_l2_power
- inverter_l3_power
- inverter_voltage
- inverter_frequency

- grid_frequency
- grid_power
- grid_l1_power
- grid_l2_power
- grid_l3_power
- grid_frequency
- grid_power
- grid_current
- grid_ct_power

- gen_power
- gen_l1_power
- gen_l2_power
- gen_l3_power

# - rated_power
- device_type
# - fault
# - overal_state
# - sd_states
- serial
- dc_transformer_temperature
- environment_temperature
# - radiator_temperature
# - grid_connected_status

# - control_mode
- grid_charge_battery_current
- grid_charge_enabled
# - battery_charging_voltage
- bat1_soc
# - bat1_cycle
# - battery_equalization_voltage
# - battery_absorption_voltage
# - battery_float_voltage
# - battery_shutdown_capacity
# - battery_restart_capacity
# - battery_low_capacity
# - battery_shutdown_voltage
# - battery_restart_voltage
# - battery_low_voltage

- priority_mode
- load_limit

- prog1_time
- prog2_time
- prog3_time
- prog4_time
- prog5_time
- prog6_time

- prog1_power
- prog2_power
- prog3_power
- prog4_power
- prog5_power
- prog6_power

- prog1_capacity
- prog2_capacity
- prog3_capacity
- prog4_capacity
- prog5_capacity
- prog6_capacity

- prog1_charge    
- prog2_charge    
- prog3_charge    
- prog4_charge    
- prog5_charge    
- prog6_charge    

# - prog1_mode
# - prog2_mode
# - prog3_mode
# - prog4_mode
# - prog5_mode
# - prog6_mode

- prog1_voltage
- prog2_voltage
- prog3_voltage
- prog4_voltage
- prog5_voltage
- prog6_voltage

@archi
Copy link

archi commented Jan 28, 2023 via email

@kababoom
Copy link
Contributor

Hmm prog mode is the combination of gen charge - grid charge..

@kellerza
Copy link
Owner

Hmm prog mode is the combination of gen charge - grid charge..

Yes, but if you define your own, you can also separate the using a bitmask=xx on the sensor definition

@sebmueller
Copy link

@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.

@kababoom : You have to install the add ons for gate and cycle in HA.

image
image

@archi
Copy link

archi commented Jan 31, 2023

Ah, @kababoom nice work on the PR :) Looking forward to test it.

Regarding the Waveshare: Keep in mind the non-PoE variant is lacking any isolation, while the PoE variant is isolated both on the Ethernet port and on RS485. The think the chance of the inverter unloading into the modbus is pretty slim, but in case of a lightning strike I didn't want to take any chances (plus, I have PoE anyway).

I can also report the configuration software runs well on my Linux machine (using wine). I did not test the automatic scan (the gateway has its own subnet and now strictly firewalled), but manually adding by IP worked well.

@kababoom
Copy link
Contributor

@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.

@kababoom : You have to install the add ons for gate and cycle in HA.

image image

@sebmueller Thank you, packages could not be found but got it working by adding the packages to the config of nodered. Looks good..

@yksxjan
Copy link

yksxjan commented Feb 19, 2023

Here is a ESP32-Deye project, if you look at the yaml file, it lists the 3P modbus registries in quite readable format, so might be useful to have a look

https://github.com/klatremis/esphome-for-deye

@bruceborrett
Copy link

Can anyone confirm how to use the definitions file added in #93? Do I have to create a local copy of the addon and rename definitions3ph.py to definitions.py? I tried doing exactly this and unfortunately it still tries to query the registers from the original definitions file, Im not where it is reading them from since I removed the original file.

@kellerza
Copy link
Owner

@bruceborrett you have to modify the addon’s Dockerfile.

There is a script called copy2local that does this and copies the files to the correct folder (modify for your target HASS IP/samba share. You will need msys to run it on windows (for sed)

@bruceborrett
Copy link

@kellerza Im running Linux and dont have any experience with Windows scripts, but will figure it out, thanks.

@kellerza
Copy link
Owner

Even better. that means you have all the linux command-line tools available already. The script will just show you what needs to go where

@bruceborrett
Copy link

Managed to get it all working and it is now reading the correct registers 🥳 Thank you

@kellerza
Copy link
Owner

kellerza commented Mar 19, 2023

The first version of the MULTI addon should be ready.

You can now select a "three-phase" inverter though config & even add your own custom sensors

And new docs 😉 https://kellerza.github.io/sunsynk/reference/definitions

The definitions3ph.py file was contributed by @kababook & @archi and hopefully they keep it up to date,- PRs always welcome

@NismoBoy34
Copy link

NismoBoy34 commented Mar 21, 2023

2023.03.19-0.3.1
running the new version as ive been waiting to test for a while and have been running on node red instead using flows for the longest time ..
two issues come up alot firstly in the logs connectivity is not stable usually takes a few tries to get the addon reading rs485 .. no other applications using the port as ive disabled node red from starting totally .

2023-03-21 10:24:20,573 INFO options Loading HASS OS configuration
2023-03-21 10:24:20,599 INFO Using three phase sensor definitions.
2023-03-21 10:24:20,602 INFO Added hidden sensors as other sensors depend on it:
2023-03-21 10:24:20,604 INFO Connecting to serial:///dev/ttyUSB0
2023-03-21 10:24:20,630 INFO Reading startup sensors serial, rated_power
2023-03-21 10:24:30,700 ERROR Read Error: (1,3,5) 'Serial' object has no attribute 'host'
2023-03-21 10:24:30,722 INFO ############################################################
2023-03-21 10:24:30,722 INFO No response on the Modbus interface serial:///dev/ttyUSB0, try checking the wiring to the Inverter, the USB-to-RS485 converter, etc
2023-03-21 10:24:30,722 INFO ############################################################
2023-03-21 10:24:30,723 CRITICAL This Add-On will terminate in 30 seconds, use the Supervisor Watchdog to restart automatically.

@NismoBoy34
Copy link

NismoBoy34 commented Mar 21, 2023

Second issue is if i run the single phase definitions i dont get any errors . ...
but if i run the 3 phase definitions selection i get this and other errors constantly ...
[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.
2023-03-21 10:28:51,735 INFO options Loading HASS OS configuration
2023-03-21 10:28:51,764 INFO Using three phase sensor definitions.
2023-03-21 10:28:51,766 INFO Added hidden sensors as other sensors depend on it:
2023-03-21 10:28:51,767 INFO Connecting to serial:///dev/ttyUSB0
2023-03-21 10:28:51,782 INFO Reading startup sensors serial, rated_power
2023-03-21 10:28:51,894 INFO ############################################################
2023-03-21 10:28:51,894 INFO Inverter serial number '2##############'
2023-03-21 10:28:51,895 INFO ############################################################
2023-03-21 10:28:51,897 INFO MQTT: Connecting to homeassistant@core-mosquitto:1883
2023-03-21 10:28:52,937 INFO MQTT: Connection successful
2023-03-21 10:30:04,339 ERROR Read Error: (1,516,4) 'Serial' object has no attribute 'host'

And more digging im finding that its to do with the Definitions file ..

2023-03-21 10:38:44,427 INFO Removing HASS MQTT discovery info homeassistant/sensor/2208077352/total_grid_export/config
2023-03-21 10:38:44,429 INFO Removing HASS MQTT discovery info homeassistant/sensor/2208077352/total_grid_import/config
2023-03-21 10:38:55,152 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:38:55,173 INFO Retrying individual sensors: ['pv1_power', 'load_power', 'load_l1_power', 'load_l2_power', 'load_l3_power', 'gen_power', 'inverter_power', 'inverter_l1_power', 'inverter_l2_power', 'inverter_l3_power', 'total_pv_energy', 'total_battery_charge', 'total_battery_discharge', 'battery_soc']
2023-03-21 10:39:05,327 ERROR Read ErrorLoad power: (1,653,1) 'Serial' object has no attribute 'host'
2023-03-21 10:39:15,436 ERROR Read ErrorLoad L1 power: (1,650,1) 'Serial' object has no attribute 'host'
2023-03-21 10:39:25,559 ERROR Read ErrorLoad L2 power: (1,651,1) 'Serial' object has no attribute 'host'
2023-03-21 10:39:35,840 ERROR Read ErrorInverter power: (1,636,1) 'Serial' object has no attribute 'host'
2023-03-21 10:39:46,166 ERROR Read ErrorTotal PV Energy: (1,534,2) 'Serial' object has no attribute 'host'
2023-03-21 10:39:46,428 WARNING Load power:step:mean: should not be None
2023-03-21 10:39:46,429 WARNING Load L1 power:step:mean: should not be None
2023-03-21 10:39:46,432 WARNING Load L2 power:step:mean: should not be None
2023-03-21 10:39:46,438 WARNING Inverter power:step:mean: should not be None
2023-03-21 10:39:46,442 WARNING Total PV Energy:last: should not be None
2023-03-21 10:40:02,524 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:40:12,604 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:40:24,718 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:40:36,812 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:40:48,907 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:41:01,000 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:41:13,090 ERROR Read Error: (1,650,4) 'Serial' object has no attribute 'host'
2023-03-21 10:41:25,189 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:41:37,280 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:41:49,376 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:42:01,470 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:42:13,564 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:42:25,651 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'
2023-03-21 10:42:35,736 ERROR Read Error: (1,633,4) 'Serial' object has no attribute 'host'

@kellerza
Copy link
Owner

Can you try using mbusd? This seems more like there is an issue with the serial driver

I don't have the capability to test the serial driver, maybe I should just force everyone to go via mbusd

@NismoBoy34
Copy link

ok

Can you try using mbusd? This seems more like there is an issue with the serial driver

I don't have the capability to test the serial driver, maybe I should just force everyone to go via mbusd

Ok installed and configured and no errors you were right thank you for that .
seems to be working okay .

@kellerza
Copy link
Owner

Great, I’m not actively using the 3ph definitions, but PRs are welcome to that file

Will see if I can setup a test env to test the serial drivers& update pymodbus to the latest release as well. There seems to be some new development happening there (there was a blocking issue with async before pymodbus 3, and the reason why I included umodbus). Umodbus seems to be very quiet recently

I have my doubts if umodbus is reliable on usb interfaces

@archi
Copy link

archi commented Mar 29, 2023

I've also got it running now, with a small test PV deployment attached to the inverter. It currently runs in a screen session on my home server, and seemed rock solid. The reported data looks correct (didn't check all, but many), and I can even control lots of things in the inverter. N.b.: I'll probably put the "addon" into a systemd service on my host machine, since it works really nice even without home assistant - I really like how you went with the MQTT approach!

What I noticed:

  1. "Battery Capacity current" is given in A, but should be Ah (and drop the "current"); I'm not sure what keyword to use there instead of AMPS.
  2. "Grid Charge enabled" is a (0,1) switch, which translates to "ON" and "OFF" in Home Assistant, while many other options/switches use "On" and "Off". This inconsistency is a bit annoying for automations, since Grid Charge enabled needs special handling (I implemented a "force charge" switch in node-red to test the balancer)
  3. Currently we don't get data reported from the BMS, like CAN connection status, single cell voltages or permitted charge/discharge current. I'm not sure if these can even be read via RS485, but I'll take a look. Would probably also benefit the 1ph inverters.
  4. For some of the RWSensors I personally would prefer to monitor them, but not allow editing them in Home Assistant (like charge/discharge current). I can just patch my local definitions, but IMHO being able to set this per-option in the yaml would be neat. [Obviously this is an suggestion for a separate issue, just let me know if I should open one or if this has been considered and deemed "not on your todo list" ;-)]

For 1&2 I guess you have to decide if these changes are okay, Johann. I'll then open a PR.

For 3. I'll try to take a look once I find some spare time.

For 4. it's up to you as well; I know how painful random user "helpful suggestions" can be for FOSS maintainers and can totally live with a local workaround.

@kellerza
Copy link
Owner

I'll probably put the "addon" into a systemd service on my host machine, since it works really nice even without home assistant - I really like how you went with the MQTT approach!

Great, glad you got it working! Do you run it natively, or do you still use Docker/Podman?

  1. "Battery Capacity current" is given in A, but should be Ah (and drop the "current"); I'm not sure what keyword to use there instead of AMPS.

This does seem incorrect, especially with a max of 2000A. For "Ah" there is no specific keyword (only voltage/current/energy have these to try and enforce some consistency)

PR welcome. I'm not too concerned about adding deprecated version, but you can always add the _deprecated logic from the 1ph definitions.py file.

  1. "Grid Charge enabled" is a (0,1) switch, which translates to "ON" and "OFF" in Home Assistant, while many other options/switches use "On" and "Off". This inconsistency is a bit annoying for automations, since Grid Charge enabled needs special handling (I implemented a "force charge" switch in node-red to test the balancer)

MQTT Switch is not something I've tested extensively. Today it is simply a special case of a MQTT select entity, but might need to check the MQTT discovery docs again.

What exactly does the "Force charge" switch do?

  1. Currently we don't get data reported from the BMS, like CAN connection status, single cell voltages or permitted charge/discharge current. I'm not sure if these can even be read via RS485, but I'll take a look. Would probably also benefit the 1ph inverters.

This will really depend on the inverter - see also #59 for another place to read up on these modbus registers

  1. For some of the RWSensors I personally would prefer to monitor them, but not allow editing them in Home Assistant (like charge/discharge current). I can just patch my local definitions, but IMHO being able to set this per-option in the yaml would be neat. [Obviously this is an suggestion for a separate issue, just let me know if I should open one or if this has been considered and deemed "not on your todo list" ;-)]

If you are willing to do a PR I'll consider this, maybe through some modifier, like the filters, say sensor:RO

My approach is to add it to the UI as an entity. Then you have to first click on it and you can change in a popup. But I fully agree that some things you don't want to set in the UI. (At the end of #59 there is one, something completely hidden from the sunsynk UI). In the normal definitions file, I have tried to steer away from what I consider dangerous settings (like changing the grid frequency, - although a user suggested you can nicely disconnect from the grid if this is wrong. It's a neat use case, but I might be a bit conservative to test it)

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - type: entity
        entity: select.ss_prog1_time
        name: '1'
      - type: entity
        entity: select.ss_prog1_charge
        name: ' '
        state_color: false
      - type: gauge
        entity: number.ss_prog1_capacity
        needle: false
        name: ' '
  - type: horizontal-stack
    cards:
      - type: entity
        entity: select.ss_prog2_time
        name: '2'
      - type: entity
        entity: select.ss_prog2_charge
        name: ' '
      - type: gauge
        entity: number.ss_prog2_capacity
        needle: false
        name: ' '

image

image

@archi
Copy link

archi commented Apr 2, 2023

Great, glad you got it working! Do you run it natively, or do you still use Docker/Podman?

Native execution inside a screen session. Since it runs well with python 3.10 from the Arch Linux repositories, I don't see a reason to put inside a container which I'd then need to update manually. If I find some time, I'll probably write a package file.

What exactly does the "Force charge" switch do?

Set the target capacity in the "time of use" config to 100% and enable grid charging. This will then fully charge the battery. I used this to charge the battery for initial balancing.

[...] but I might be a bit conservative to test it)

haha, I feel very much the same :)

Regarding the other points, I'll try to look into these once I have some time on my hands :)
Though with the current state I'm already very happy.

@kellerza
Copy link
Owner

What exactly does the "Force charge" switch do?

Set the target capacity in the "time of use" config to 100% and enable grid charging. This will then fully charge the battery. I used this to charge the battery for initial balancing.

This seems like a combination of the writable sensors grid_charge_enabled and prog1_capacity..prog6_capacity

@kellerza
Copy link
Owner

The MULTI addon allows you to use the three-phase definitions - https://kellerza.github.io/sunsynk/reference/definitions#three-phase-inverter-sensor-definitions

For any specific issues on the 3ph definitions, please open a PR/new issue

@khems
Copy link

khems commented May 17, 2023

Which port did you guys plug into in the end? Meter 485? Or did you have to split the BMS port in the end?

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