fboundy / pv_opt

Home Assistant PV Optimisation for Solis Inverters
MIT License
19 stars 4 forks source link

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

Open ElectricMolehill opened 4 months ago

ElectricMolehill commented 4 months ago

Hi fboundy

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

ElectricMolehill commented 3 months ago

@fboundy just re-read your post and realised you're talking about directly connecting to the Sunsynk API, not a wired modbus connection. I think that could work but I don't have any documentation of it apart from unofficial lists of json keys. I guess you could copy one of the integrations already published in Github

alz41 commented 3 months ago

@ElectricMolehill I'm having the same sort of problems with that integration. Regarding modbus connection iv been running solar assistant connected via splitter on the battery input for six months with no problems.

fboundy commented 3 months ago

All the necessary API calls appear to be in the solarsync add-on bash script but it would be rather duplicating effort.

alpha-13 should be working now I think

ElectricMolehill commented 3 months ago

alpha-13 - there's a type error: TypeError: object of type 'bool' has no len() error.log main.log pv_opt.log Connecting direct to Sunsynk API - yes let's give it a go. It's a shame to duplicate effort but the Solarsynk add-on doesn't have the features we need and it's not really feasible to add them. We could try the MorneSaunders integration but it sounds like that also has a connectivity issue and it would be quite a bit of work before we know whether it's suitable. It's mostly your time so I'm happy to go with whichever you think has the best prospects

fboundy commented 3 months ago

FIxed in 4.0.0-sunsynk-alpha-14

Once let's see if we can consistently get charge plans in read-only and then we'll make a call on which route to go down for control

ElectricMolehill commented 3 months ago

That's looking good so far. Perhaps I'd better leave it running for a few days to give it a proper run with better data. I missed a day's inverter history in HA yesterday because the Sunsynk dongle lost contact with my local network when the clocks changed and I didn't discover a fix until yesterday evening Good news is, Solarsynk has been patched to handle connectivity failures more gracefully. Also it sounds like the connectivity issues may have been something to do with verification of SSL certificates since Sunsynk.net changed certificates. The cause of this is still not known so unfortunately the workaround is to disable verification. Still, that might close up the gaps in the data error.log main.log pv_opt.log

alz41 commented 3 months ago

@fboundy should the pvopt entities be created? With current release

fboundy commented 3 months ago

Should be. If they aren’t it suggests an error. What does error.log say? On 1 Apr 2024 at 17:12 +0100, alz41 @.***>, wrote:

@fboundy should the pvopt entities be created? With current release — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

alz41 commented 3 months ago

Should be. If they aren’t it suggests an error. What does error.log say? On 1 Apr 2024 at 17:12 +0100, alz41 @.>, wrote: @fboundy should the pvopt entities be created? With current release — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.>

main.log error.log pv_opt.log

alz41 commented 3 months ago

logs for alpha15

entities still not created for dashboard

error.log main.log pv_opt.log

fboundy commented 3 months ago

The last error.log was empty. Could you please re-upload?

alz41 commented 3 months ago

It was empty at the time of posting

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: fboundy @.> Sent: Wednesday, April 3, 2024 2:27:50 PM To: fboundy/pv_opt @.> Cc: alz41 @.>; Mention @.> Subject: Re: [fboundy/pv_opt] Support for Sunsynk inverter via Solarsynk2 add-on for Home Assistant (Issue #129)

The last error.log was empty. Could you please re-upload?

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

fboundy commented 3 months ago

Ok - maybe that it had just rolled over into a new file. Is there anything in error.log.1? On 3 Apr 2024 at 14:59 +0100, alz41 @.***>, wrote:

It was empty at the time of posting

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: fboundy @.> Sent: Wednesday, April 3, 2024 2:27:50 PM To: fboundy/pv_opt @.> Cc: alz41 @.>; Mention @.> Subject: Re: [fboundy/pv_opt] Support for Sunsynk inverter via Solarsynk2 add-on for Home Assistant (Issue #129)

The last error.log was empty. Could you please re-upload?

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

ElectricMolehill commented 3 months ago

@alz41 is Mosquitto running OK?

alz41 commented 3 months ago

@fboundy whats strange is the sensors are created but not the helpers

LOG AFTER 30MINS OF RUNNING (ERROR LOG [EMPTY)

error.log main.log pv_opt.log

fboundy commented 3 months ago

OK - I'll try to get an update out tomorrow which is up to date with the main beta version. Might help

alz41 commented 3 months ago

OK - I'll try to get an update out tomorrow which is up to date with the main beta version. Might help

thanks

Mosquitto log shows connection as below

Mosquitto broker 2024-04-03 19:06:31: New client connected from 172.30.33.6:55967 as localad (p2, c1, k60, u'PV_OPT').

fboundy commented 3 months ago

I've just released 3.14.0-alpha-16 (decided that this won't be v4 after all) which should have a lot more functioning features. It doesn't write to the solarsynk helper entity but it writes the JSON that it would have written to the log file.

I'm trying to get all these various features into 3.14.0 and get that out asap so let me know what you find

alz41 commented 3 months ago

3.14.0-alpha-16 helpers still not being created

error.log main.log pv_opt.log

Mosquitto.log 2024-04-04 21:51:52: New connection from 172.30.33.6:52653 on port 1883. 2024-04-04 21:51:52: New client connected from 172.30.33.6:52653 as localad (p2, c1, k60, u'PV_OPT').

Supervisor.log 2024-04-04 20:48:11.237 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'PV_OPT' 2024-04-04 20:48:11.711 INFO (MainThread) [supervisor.auth] Successful login for 'PV_OPT' 2024-04-04 20:57:04.842 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'PV_OPT' 2024-04-04 20:57:05.317 INFO (MainThread) [supervisor.auth] Successful login for 'PV_OPT' 2024-04-04 21:51:52.312 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'PV_OPT' 2024-04-04 21:51:53.567 INFO (MainThread) [supervisor.auth] Successful login for 'PV_OPT'

fboundy commented 3 months ago

Does sound like an MQTT problem. On 4 Apr 2024 at 22:15 +0100, alz41 @.***>, wrote:

3.14.0-alpha-16 helpers still not being created error.log main.log pv_opt.log Mosquitto.log 2024-04-04 21:51:52: New connection from 172.30.33.6:52653 on port 1883. 2024-04-04 21:51:52: New client connected from 172.30.33.6:52653 as localad (p2, c1, k60, u'PV_OPT'). Supervisor.log 2024-04-04 20:48:11.237 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'PV_OPT' 2024-04-04 20:48:11.711 INFO (MainThread) [supervisor.auth] Successful login for 'PV_OPT' 2024-04-04 20:57:04.842 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'PV_OPT' 2024-04-04 20:57:05.317 INFO (MainThread) [supervisor.auth] Successful login for 'PV_OPT' 2024-04-04 21:51:52.312 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'PV_OPT' 2024-04-04 21:51:53.567 INFO (MainThread) [supervisor.auth] Successful login for 'PV_OPT' — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

alz41 commented 3 months ago

Does sound like an MQTT problem.

solar assistant works fine with MQTT, ANY IDEA HOW TO DEBUG. Have already uninstalled rebooted and reinstalled still same error

fboundy commented 2 months ago

I've successfully debugged MQTT issues with MQTT Explorer in the past.

There is an error being caused by a bug in the sunsynk controller which I will fix for the next release . This isn't related to the MQTT but if we can get everything else running perhaps we can diagnose better.

alz41 commented 2 months ago

Sounds good to me

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: fboundy @.> Sent: Monday, April 8, 2024 7:11:25 PM To: fboundy/pv_opt @.> Cc: alz41 @.>; Mention @.> Subject: Re: [fboundy/pv_opt] Support for Sunsynk inverter via Solarsynk2 add-on for Home Assistant (Issue #129)

I've successfully debugged MQTT issues with MQTT Explorer in the past.

There is an error being caused by a bug in the sunsynk controller which I will fix for the next release . This isn't related to the MQTT but if we can get everything else running perhaps we can diagnose better.

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

fboundy commented 2 months ago

Should be fixed in the 3.14.0 release

alz41 commented 2 months ago

logs from 3.14.0 release 14:37:26 WARNING pv_opt: Unexpected error in worker for App pv_opt:

error.log main.log pv_opt.log

alz41 commented 2 months ago

@alz41 is Mosquitto running OK?

@ElectricMolehill Yes, Sensors show when i connect with MQTT EXPLORER but not showing in Home Assistant

fboundy commented 2 months ago

I'm away for a couple of days. Will try to look when I'm back

ElectricMolehill commented 2 months ago

I installed v3.14.1 - it's running fine but I had to add 2 lines to config.yaml:

I had to spell out inverter_sn explicitly in both cases as pv_opt did not pick it up from config Solarsynk has 1 power sensor for each PV string pv1 and pv2. It doesn't have a total value for pv power but it does for battery related sensors such as battery_power1 / battery_power2 and battery_power so perhaps I could ask for a total to be added

Good news is, Solarsynk is now running reliably with no dropouts since SSL certificate checking was disabled image (ignore the glitch yesterday just after 21:00 - I accidentally pulled the network cable loose)

I think I misunderstood the meaning of 'Hold SOC' when I sent you my documentation. Does it mean - 'maintain SOC for a 15 min timeslot without charging or discharging at all'? If so then I was wrong and there is a way to do this. I'll need to do some more testing to confirm the best way to do it

error.log main.log pv_opt.log

alz41 commented 2 months ago

version 3.14.2 logs

error.log main.log pv_opt.log

fboundy commented 2 months ago

@alz41: 3.14.3 should fix the error in solarsynk_set_helper

@ElectricMolehill: It should also allow you to specify two a list of entities for the solar power:

  id_solar_power: 
    - sensor.{device_name}_pv_power_1
    - sensor.{device_name}_pv_power_2
alz41 commented 2 months ago

3.14.3 logs

WARNING pv_opt: Unexpected error in worker for App pv_opt:

error.log main.log pv_opt.log

alz41 commented 2 months ago

after changing overwrite_ha_on_restart: to false and ev charger to none everything working as expected.

should PVOPT be making changes to inverter settings for charge/discharge?

fboundy commented 2 months ago

At present it should just be writing the state of the Solarsynk helper to the log but I've just spotted a typo. I will fix and issue an update but if you want to edit yourself it is line 135 in sunsynk.py. It should be:

    self.rlog(f"Setting SolarSynk input helper {entity_id} to {new_json}")
alz41 commented 2 months ago

@fboundy

At present it should just be writing the state of the Solarsynk helper to the log but I've just spotted a typo. I will fix and issue an update but if you want to edit yourself it is line 135 in sunsynk.py. It should be:

    self.rlog(f"Setting SolarSynk input helper {entity_id} to {new_json}")

Made the above change, Clicking send to inverter on the Pvopt test card raises the following error - pandas._libs.tslibs.parsing.DateParseError: Unknown datetime string format, unable to parse: sensor.{device_name}_2301058444_prog1_time

Full logs below error.log main.log pv_opt.log

alz41 commented 2 months ago

Rebooting HA with read only set true in Pvop config runs, but setting read only false gives error

error.log main.log pv_opt.log

ElectricMolehill commented 2 months ago

I've updated my sunsynk document to include some new information such as

fboundy commented 2 months ago

Been tied up with other things but will hopefully get back on this next week

ElectricMolehill commented 2 months ago

I've had pv_opt running in read only mode for a couple of weeks now without error. I don't always understand the plan it produces but that is probably because I don't understand the algorithm. Solarsynk is also running reliably now since the CA cert check was removed

fboundy commented 2 months ago

Can you upload the pv_opt.log file so I can see what it’s doing?

Thanks On 28 Apr 2024 at 17:08 +0100, Mark W (UK) @.***>, wrote:

I've had pv_opt running in read only mode for a couple of weeks now without error. I don't always understand the plan it produces but that is probably because I don't understand the algorithm. Solarsynk is also running reliably now since the CA cert check was removed — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

ElectricMolehill commented 2 months ago

pv_opt.log

alz41 commented 2 months ago

reboot HA First load logs error.log main.log pv_opt.log

change ev charge to none @ 17:34 error.log main.log pv_opt.log

github-actions[bot] commented 6 days ago

Stale issue message