pv_opt icon indicating copy to clipboard operation
pv_opt copied to clipboard

Support for Sunsynk inverter via Solarsynk2 add-on for Home Assistant

Open ElectricMolehill opened this issue 1 year ago • 91 comments

Hi fboundy

  • this is fantastic, just what I was looking for. Unfortunately I bought a solar system before coming across pv_opt and it's Sunsynk. Sorry I'm not qualified to write the inverter class would you consider doing it? I have written up what I know in the attached document and also completed the template below. There are one or two gaps, maybe we can fill them by testing or asking the developer of the solarsynk2 add-on martinville

regards Mark

PV Opt can be updated to support additional models and brands of inverter. If you want to request this, please supply as much of the following information as possible:

Home Assistant Entities to Read

PV Opt reads data from a number of entities in Home Assistant. These will vary by inverter. Please document what your inverter provides. Examples are provided from the Solis Solax Modbus integration:
Battery minimum SOC: number.solis_battery_minimum_soc
Battery SOC:         sensor.solis_battery_soc
Either:
  Load power:        [sensor.solis_house_load, sensor.solis_bypass_load], or
  Load today:        sensor.solis_house_load_today
Either:
  Grid import power: sensor.solis_grid_import_power and
  Grid export power: sensor.solis_grid_export_power
Or:
  Grid import today: sensor.solis_grid_import_today and
  Grid export today: sensor.solis_grid_export_today

Inverter Control

PV Opt also needs to control your inverter. How this is done and what can be done varies hugely by brand, by model and by the integration you use with Home Assistant. Please provide as much detail under each heading. Examples are provided for the Solis inverter using the both the Solax Modbus Integration and the HA Core Modbus functionality. Please add your details below:

Examples

Solis Solax Modbus Solis Core HA Modbus
How do you enable forced charging? Only done via timed charge Only done via timed charge
How do you enable forced discharging? Only done via timed discharge Only done via distimed charge
Are forced charge and discharge controlled using Power or Current? Current Current
Does your inverter support timed charging slots? Yes Yes
Does your inverter support timed discharging slots? Yes Yes
How do you enabled timed charge? Set the following: number.timed_charge_start_hour, number.timed_charge_start_minute, number.timed_charge_end_hour, number.timed_charge_start_minute. Then press 'button.solis_update_charge_discharge_times. Set the required current to number.solis_timed_charge_current. Ensure select.solis_energy_storage_control_switch has Timed Grid Charging enabled. Use the modbus\write_register service to write start and end hours and minutes to the correct registers. Ensure the energy_storage_control_switch has Bits 2 and 5 enabled. Set the required current using the modbus\write_register service
How do you enabled timed charge? As for charging but all entities are discharge rather than charge As for charging but registers are different.
Can you set a target SOC for a timed charge period? No No
Can you set a target SOC for a timed discharge period? No No
What modes does you inverter have and how are they controlled? One register on the inverter Energy Control Switch which controls mode in a bit-wise sense. Only some modes can be selected vai the entity select.solis_energy_storage_control_switch One register on the inverter Energy Control Switch which controls mode in a bit-wise sense. The required number is set using the modbus\write_register service

Your Setup

What is the inverter brand?

Sunsynk

What is the inverter model?

ECCO 3.6kW hybrid inverter SYNK-3.6K-SG04LP1

What integration do you use in Home Assistant

Solarsynk2 add-on. There is another one Deye/Sunsynk Home Assistant add-on by kellerza but this requires a direct wired connection to the inverter

How do you enable forced charging?

Only done via a timer. Set a time slot x, tick grid time x to allow charging from grid, target SOC x (above current SOC) and power x. 6 slots are available

How do you enable forced discharging?

Only done via a timer. Set a time slot x, tick grid time x to allow charging from grid, target SOC x (below current SOC) and power x

Are forced charge and discharge controlled using Power or Current?

Power (W) and target SOC whichever is the smaller

Does your inverter support timed charging slots?

6 slots used for charge and discharge. Should be contiguous, sequential and cover the whole 24 hrs

Does your inverter support timed discharging slots?

Same timeslots as for charging but with a different target SOC

How do you enabled timed charge?

Set Use Timer = true To do this, populate helper input_text.solarsynk_{inverter serial no}_settings with json to update Sunsynk cloud api: {"peakAndVallery": "1"} (just possible this is a misspelling) Also required for slot x - Start time ("sellTime(x)": "02:00") Grid timer x ("time(x)on": true) Target SOC ("cap(x)": "80") if this is higher value than current SOC, batteries wil charge up to this value from the grid Power x ("sellTime(x)Pac": "3600") End time is defined implicitly by the start time of the next slot. An appdaemon process runs every 5 min to post the contents of this helper to the Sunsunk cloud api. This is not ideal because it's not online. Perhaps I could get the Solarsynk developer martinville to add a realtime update method

How do you enabled timed discharge?

As for charging but set target SOC low

Can you set a target SOC for a timed charge period?

Yes - this would be the usual manual method

Can you set a target SOC for a timed discharge period?

Yes

What modes does you inverter have and how are they controlled?

There are some settings which limit export to load or grid. Details to be confirmed but probably should be set manually

Any other useful information

See attached doc [sunsynk inverter class for pv_opt.odt](https://github.com/fboundy/pv_opt/files/14324224/sunsynk.inverter.class.for.pv_opt.odt)

ElectricMolehill avatar Feb 18 '24 20:02 ElectricMolehill

Forgot to add HA entities to read:

Battery minimum SOC: sensor.solarsynk_{inverter sn}_battery_shutdown_cap (%)
Battery SOC:         sensor.solarsynk_{inverter sn}_battery_soc (%)
Either:
  Load power:        sensor.solarsynk_{inverter sn}_load_power (kW), or
  Load today:        sensor.solarsynk_{inverter sn}_day_load_energy (i.e kWh)
Either:
  Grid import power: sensor.solarsynk_{inverter sn}_grid_power (this is probably total import and export)
  Grid export power: 
Or:
  Grid import today: sensor.solarsynk_{inverter sn}_day_grid_import (kWh) and
  Grid export today: sensor.solarsynk_{inverter sn}_day_grid_export (kWh)

ElectricMolehill avatar Feb 18 '24 20:02 ElectricMolehill

I can certainly try to get something working for you. It may take a while - need to solve a few other bugs 1st.

fboundy avatar Feb 19 '24 18:02 fboundy

That's great, thankyou. The installation's only been in for a week and we're not certified to export yet. Then I'll need to familiarise myself with programming it manually. What do you think about the update settings method provided by the Solarsynk add-on? It takes up to 5 min to send to the cloud, then maybe another 5 min until the results are readable from HA sensors. Is that fast enough?

regards Mark

ElectricMolehill avatar Feb 19 '24 20:02 ElectricMolehill

OK - I've had a very preliminary start at this. It will is v4.0.0-alpha-1 pre-release so you will need to enable Beta versions in HACS and manually select it. You will also need the config_sunsynk.yaml file from the GitHub release or the branch associated with this Issue (rename it to config.yaml

If you are very lucky it might work in Read Only mode! Either way please send me the logs. In the meantime I will try to have a look at the documentation for the integration.

fboundy avatar Feb 23 '24 18:02 fboundy

Thanks I'll give it a go! I'll try to clarify the working modes for the inverter tomorrow - they control whether the inverter gives priority to essential load / non-essential load / battery / grid export. I've also discovered another check we should do - the inverter will support battery types which use voltage instead of SOC to control charge / discharge so we should check that the battery is compatible with SOC. Also, I think my documentation is wrong about ticking 'Grid' for a discharge, it looks like it should be unticked. I'll update the documentation

ElectricMolehill avatar Feb 23 '24 18:02 ElectricMolehill

Sorry my mistake - {inverter sn} should be {sunsynk_serial} as defined in solarsynk addon. Also - cosmetic change - could you change the spelling of solarsync2 to solarsynk2 please. I don't know how far I can get with testing because we're not certified for export yet so we haven't changed tariff from the fixed rate Flexible Octopus to some thing smart such as Agile or Flux. Unless there's a way to bypass it for testing purposes?

ElectricMolehill avatar Feb 23 '24 20:02 ElectricMolehill

I think there are 2 typos in sunsynk.py: image

ElectricMolehill avatar Feb 24 '24 09:02 ElectricMolehill

Is there any way of extracting {sunsynk_serial} from the addon? If not I might prefer to keep {inverter_sn} as a generic parameter across brands. Will fix the typos now and re-release as alpha-2

fboundy avatar Feb 24 '24 09:02 fboundy

alpha-2 available. You will need to manually copy config-sunsynk.yaml

fboundy avatar Feb 24 '24 09:02 fboundy

[sunsynk_serial} is in the config for the Solarsynk add-on but I can't see a sensor for it

ElectricMolehill avatar Feb 24 '24 09:02 ElectricMolehill

OK - then it shouldn't matter if we call it something else in the config file. I suspect other brand/integrations may need something similar so I'd rather keep it generic where possible


From: Mark W (UK) @.> Sent: 24 February 2024 09:58 To: fboundy/pv_opt @.> Cc: fboundy @.>; Comment @.> Subject: Re: [fboundy/pv_opt] Support for Sunsynk inverter via Solarsynk2 add-on for Home Assistant (Issue #129)

[sunsynk_serial} is in the config for the Solarsynk add-on but I can't see a sensor for it

— Reply to this email directly, view it on GitHubhttps://github.com/fboundy/pv_opt/issues/129#issuecomment-1962315589, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABHJ7POK2BADLACPAGPJUUTYVG2TRAVCNFSM6AAAAABDONK3YGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSGMYTKNJYHE. You are receiving this because you commented.Message ID: @.***>

fboundy avatar Feb 24 '24 10:02 fboundy

Sorry but I think there's another typo: image

ElectricMolehill avatar Feb 24 '24 14:02 ElectricMolehill

Also I think the underline character is missing in {inverter_sn} on all of the sensors above

ElectricMolehill avatar Feb 24 '24 14:02 ElectricMolehill

Updated my documentation for the inverter. There are a couple of problems, such as

  • No method in Solarsynk integration to check max power of inverter
  • No method in Solarsynk integration to check whether an Auxiliary power source (e.g. generator / wind turbine) is connected which I imagine would invalidate a pv_opt plan
  • The Solarsynk update method is based on a batch process and takes 5 - 10 minutes to return, plus the return codes are only visible in the Solarsynk log

Apart from that I think it should work! sunsynk inverter class for pv_opt v2.odt

ElectricMolehill avatar Feb 24 '24 19:02 ElectricMolehill

That's great - I will have a proper read of this now and have a think about how to implement it

fboundy avatar Feb 25 '24 11:02 fboundy

Here are the logs from running v4.0.0 alpha2 error.log main.log pv_opt.log

ElectricMolehill avatar Mar 04 '24 15:03 ElectricMolehill

Cheers

Away on holiday this week. Will have a look when I’m back. On 4 Mar 2024 at 16:00 +0100, Mark W (UK) @.***>, wrote:

Here are the logs from running v4.0.0 alpha2 error.log main.log pv_opt.log — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

fboundy avatar Mar 06 '24 08:03 fboundy

Hope you're having a nice holiday. I made some progress by hard coding the inverter serial number in config.yaml (inverter serial number redacted manually - 10 digits, also my Octopus account has an e instead of an m):

image image

Now pv_opt gets further: error.log main.log pv_opt.log

You'll see I'm on the Octopus Flux tariff for import but don't yet have an export tariff. I have submitted the MCS certificate and permission from the DNO but I think it can take weeks to get an export MPAN number

ElectricMolehill avatar Mar 07 '24 15:03 ElectricMolehill

following developments

alz41 avatar Mar 09 '24 23:03 alz41

I've synced this branch up with the main branch so it should now handle the lack of an export contract OK which was the point of failure before. Also added the inverter_sn to the redaction list. Released as 4.0.0-alpha3

fboundy avatar Mar 16 '24 11:03 fboundy

Hope you had a good holiday! We got our export MPAN this morning but Octopus don't seem to have taken any readings yet. Perhaps overnight. I reloaded the Octopus integration in HA and the export sensors appeared. I installed pv_opt 4.0.0-alpha4 and ran again. I reverted to the config_sunsynk.yaml from GitHub and used this to overwrite my config.yaml because pv_opt doesn't seem to be picking up some values correctly. I edited it to add the correct value of {inverter_sn}. From the logs it looks like pv_opt isn't picking up {device_name} or {inverter_sn}. Also I think there are a couple of typos in config.yaml:

  • inverter_type: "SUNSYNK_SOLARSYNC2" should be inverter_type: "SUNSYNK_SOLARSYNK2"
  • "maximum_dod_percent": "sensor.{device_name}_{inverter sn}_battery_shutdown_cap" # presumably should be {inverter_sn}
  • "id_battery_soc": " sensor.{device_name}_{inverter sn}_battery_soc" # as above underline character missing
  • "id_consumption_today": "sensor.{device_name}_{inverter sn}_day_load_energy" # as above, underline character missing
  • "id_grid_import_today": "sensor.{device_name}_{inverter sn}_day_grid_import" # as above, underline character missing
  • "id_grid_export_today": "sensor.{device_name}_{inverter sn}_day_grid_import" # as above, underline character missing, also I think import should be export error.log main.log pv_opt.log Also I think redaction list needs another line for my MPAN number which is of the form 99e9999999_9999999999999 instead of 99m9999999_9999999999999 (perhaps e and m are region markers?)

ElectricMolehill avatar Mar 16 '24 22:03 ElectricMolehill

Thanks for this. In 4.0.0-alpha-5 I have removed config-sunsynk.yaml and merged all the changes in to the main config.yaml. You should just need to un-comment the final block of parameters in this file.

I've also updated the regex pattern for the MPAN.

Hopefully with the correction of SOLARSYNC2 to SOLARSYNK2 it should get a bit further. Let me know how you get on.

fboundy avatar Mar 17 '24 17:03 fboundy

Thanks - got a lot further this time but still seems to be ending with an error: ValueError: cannot reindex on an axis with duplicate labels Redaction mostly working but there are a couple of lines in pv_opt.log still containing inverter serial number and account_MPAN number One of the defaults in config.yaml still looks wrong : image Think this should read id_grid_export_today: sensor.{device_name}_{inverter_sn}day_grid_export instead of id_grid_export_today: sensor.{device_name}{inverter_sn}_day_grid_import error.log main.log pv_opt.log

ElectricMolehill avatar Mar 17 '24 21:03 ElectricMolehill

would really like to get this working

alz41 avatar Mar 25 '24 21:03 alz41

OK - apologies for the delay. Please can you try pre-release 4.0.0-sunsynk-alpha-7 which should address the issues above and also includes various patches made to the production release.

fboundy avatar Mar 27 '24 10:03 fboundy

Thanks I'll give it a go. Actually I wasn't ready until today - SSD failed and it's taken me a week to get a replacement and recover Home Assistant from backup. We've also got some persistent connectivity problems with Solarsynk as a result of which my updates from a couple of HA automations don't seem to be working. It seems to be affecting all users of Solarsynk so it might be the cloud app that is at fault. On the plus side I'm now exporting to the grid and getting paid for it. As a result I've found out more about the Sunsynk inverter's eccentricities. For example, charge current is not controlled by the timers. Also, to discharge the batteries to the grid I need to change the Work Mode from 'Limited to Home' = 2 to 'Selling First' = 0 in real time because otherwise I can't discharge the battery to Home at other times without exporting as well. I've also found a different Sunsynk HA integration by MorneSaunders360 which also works via the cloud API but has an HA service to update the inverter which might be more appropriate for pv_opt. I'll have a look at that. In the meantime I have updated my documentation - sorry if I've misled you so far! sunsynk inverter class for pv_opt v3.odt

ElectricMolehill avatar Mar 27 '24 21:03 ElectricMolehill

OK - apologies for the delay. Please can you try pre-release 4.0.0-sunsynk-alpha-7 which should address the issues above and also includes various patches made to the production release.

Currently unable to test properly due to ongoing problems with Solarsynk.

Sunsynk.py still has references to "SUNSYNK_SOLARSYNC2" should be "SUNSYNK_SOLARSYNK2" (Lines 72, 86, 117)

error.log main.log pv_opt.log

alz41 avatar Mar 27 '24 22:03 alz41

4.0.0-sunsynk-alpha-8 should fix the typos and also bring the underlying code up to date with the latest production release

fboundy avatar Mar 28 '24 11:03 fboundy

I think I've got the latest version but it's reporting

  • PV Opt v4.0.0-4.0.0-sunsynk-alpha-7 in the pv_opt.log

When I start the application it is stuck at 'Initialising PV model'. There is a warning in error.log:

ElectricMolehill avatar Mar 28 '24 17:03 ElectricMolehill

Sorry about that. Fixed both of those so the latest is still 4.0.0-sunsynk-alpha-8

fboundy avatar Mar 28 '24 19:03 fboundy