Growatt Inverter Mode Switch

Ooops. I merged into main by accident. Oh well… it feels good to go. Github noob!
I’ll have to update the wiki sooner rather than later.

No worries @muppet3000 - happy to help. I dont think we need to maintain this script if the HACS integration has these extra features. I’ve not created anything particularly complex (and my python could do with some finessing), but I think it’s been helpful to explore see what different ways people need the basics.

@affer if you would like to share your nodered in the wiki, I’d be happy to pull that in. I cant get my head around the way it works, but I know some people love it!

P.s. I’ve created a dashboard for my home energy usage. Something else I’ve been meaning to share. Data is real time through solarassistant mqtt feed, so it refreshes every few seconds. I’ve been trying to reduce grid usage by staying within the capabilities of the inverter. Wife has found it quite helpful since the “max” output changes depending on the amount of solar generated at any given time.

A work in progress … again …

Home · mjdyson/ha-inverter-dashboard Wiki (github.com)

1 Like

here is my working nodered - it is used on a sph3600 and in danish conditions, use it as an idea what can be done - i am pretty sure i will change it a bit during the year to fit the conditions changing.

In Denmark we have high tariff on electricity in my area from 17-20, and cheap electricity during the night… as of writing we also have short days and the sun is not high on the sky (low production)

So when i found this i could finally get some logic to charge/and discharge my main SPH.

all is done in a HA installation with node-red plugin.

first is the implementation of the opportunities from HA into node-red: HA Growatt Node-red - Pastebin.com

The above is using all the functions from the Growatt Inverter Mode Switch implementation mjdyson have made. and with correct entities as of mid jan 2023

Feel free to use this directly, should work after import, no special packages other than node-red needed.

Then is the logic i am using for my setup, i will try to get into some details, but feel free to ask.

My setup is that i either runs in battery first, or load first mode - and switching these two modes on and off, it is more or less hardcoded for what i have at my home and in my HA installation, but use it as inspiration, i am no coder, so i am sure it could be done in a lot of different ways, but i all work for me. :slight_smile: Logic 1 and logic 2 - Pastebin.com

Logic 1 have three main functions:

  1. turn off battery discharge when SoC is below 60%
  2. turn off battery discharge when EV is charging
  3. turn on battery discharge at 70%
    And the Cron plus function calls discharge at high tariff (load first@1700)

Logic 2 have two main functions:

  1. charge battery at cheapest price during sunset to sunrise (external function from pvprodk (Jonas) · GitHub)
  2. enable ‘load first’ two hours before sunrise

a lot of the functions is used only during the day (when sun is up) So here is the explaining:

i start the day two hours before sunrise, the systems goes into load first and starts discharging the battery (logic 2.2)… if during the day my SoC comes below 60% i stop discharging my battery (logic 1.1) if sun have charged my batteries enough to get to 70% soc i trigger logic 1.3 (load first). otherwise i will go into load first again ay 1700. On sunny days i do not go under 60% before the sun is up and recharging the battery. the 60% is chosen because then i have enough battery SoC for my usage from 1700 to empty (15% SoC)

For battery turn off discharge i set the settings to Battery first, with an max SoC at 10% (this will then not AC charge the battery, because i expect my battery to be above 10%) but it will disable ‘load first’

if i start charging my EV, and the charging power goes over 1kW, it triggers logic 1.2 (go in to battery first at 10%) and then pauses the ‘load first’ state, enabling no discharge from my growatt system in to my car.

For charging my battery during the cheapest period of the night i have a custom made plugin from pvprodk (Jonas) · GitHub that tells me when it is the cheapest time to charge in a defined time frame (often during the night) this function will trigger the AC charge to the battery and start fill the battery and when it is filled, and the time is two hours before sunrise it all starts over.

TLDR; switching between “load first” and “battery first” and SoC setting 10 and 100.

2 Likes

Very inspiring! I consider connecting a battery to my min 3600 tl-xh, but I am looking for the right documentation to see what modes are supported. I do need AC charging for the winter to charge when the electricity is cheap and I do need control over the amount of discharge.

Hi @kiss81 ,

Apologies on my part that the wiki hasnt yet been updated with the newer details on. Hopefully I’ll have time at the weekend to sort it. In the meanwhile, there’s a testing section on the wiki that describes how the newer approach fits in. Bear in mind though, it’s only an example of how appdaemon can be used to interact with the python library that previously existed. Some coding may be necessary.

As for your inverter, it could be possible. However, not covered in my example. You would need to do some tweaking to work out which function to call in the GrowattServer.py code to change the correct parameters. Specifically, the line that includes ‘mix_ac_charge_timr_period’ - which is unique to the sph/hybrid/mix inverters.

HTH

2 Likes

Hi! As a new owner of a Growatt inverter and batteries I discovered this nice thing a few days ago. Setting upp AppDaemon and understanding how to get these Python-apps running took a few hours.
I have managed to get the get_device_ids to return a list of 2 serial numbers (the inverter and the smart meter)
I also added some log lines to get_charge_settings just to see what I get back from Growatt servers when api.get_mix_inverter_settings(device_sn) is called but it looks like I get a 503 because the response from that function looks like this:

 {'deviceType': 0, 'msg': '503', 'result': 0, 'dtc': 0, 'haveMeter': 0, 'obj': None, 'normalPower': 0, 'model': ''}

Is this a know bug, that that part of the API is not available at the moment?

If you’re getting device ids, I think you’ve got things set up properly. I’ve struggled to get responses from the server at times with lots of timeouts. Not sure what error message was returned but 503 is familiar.

I often do a trace route to the server to see if it’s my firewall blocking it. It often seems to timeout as it bounces around the latter part of the data centre (I presume).

I could do with asking the AD discord server to see if they can suggest a way to report the errors back the the UI. It would be helpful to see if its a timeout or being blocked.

Looking closer at the code and adding some more logging I can see that the status code of the response is 200 and the response message then contains the 503.

By the way, the “normal” Growatt Server API integration works so I have all the entities that comes from that one working in HA

Also, the time schedule in the ShinePhone app on my phone only contains <null> everywhere - even though I have setup a working charge schedule using my browser. Don’t know if that’s a clue…

Which inverter do you have? The code example is only for a hybrid inverter SPH-xxxx, hence the ‘mix’ part of the code.

I’ve run my script here just now and it seems to be working as expected today. Is anybody else here seeing errors today?

I have a Growatt MOD 10KTL3-XH

Aha. In that case, have a look through the growattServer file. You may find other ops that work for your setup. I’d be happy to build something in to my code, but it’s really difficult to access without the hardware :slight_smile:

1 Like

Hello, good morning. I would like to know if my growatt min 10000TL-XH-US inverter can be integrated into the monitoring system. I remember my system has no batteries. I would still like to look at my consumption and what my inverter is delivering

Hello. Whilst this discussion might be able to help, you would be better to install the general growatt hacs app linked earlier by @muppet3000. The discussion here is trying to cobble together some controls for changing modes on a schedule. Good luck!

what is this app

@mjdyson Thanks for all the work you have put in here. I am fairly new to HA but have managed to get the AD code to work with my Growatt inverter. I am keen to configure the windows for discharging the batteries to the grid for when the selling rates are high but I see the code here only sets the Discharge SOC. Do you know the syntax of the API call to update the inverter to do this?

I’m amazed this thread continues to grow! :slight_smile: How would you feel working up a PR? I’m happy to help guide you towards the details, but not sure how much time I can add over the next couple of weeks.

@Spenny99 - can I double check you mean the Grid First Discharge Scheduling? Per the image attached? i will look into this for you and let you know.

The discharge settings added recently to the testing branch are for Load First, which doesnt need schedule settings since it is the default mode (when all other modes are not scheduled).

@mjdyson Thanks. I am more than happy to help out here and write some code to achieve this. The screen you have put is exactly what I am after. I think if I just get a clue on the “update_mix_inverter_setting” call that can set this then I can do it.


mjdyson - if it is even possible… i would love this function to be implemented… and i know some german people would love that too :slight_smile: thanks for your effort - do you have an eta on the wiki update ?

Im sure it’s possible… I’ll have a look and see what I can dig up.

I’ve found something for the discharge rates, but I’d like to test before I release. I have a suspicion that we need to check for overlapping schedule windows.

Re: the wiki update. I’m honestly looking for an hour or two on a weekend. Life’s been hectic so far in 2023! :slight_smile:

I’ve also found something for the export limit. So that’s promising. No major changes required at all :slight_smile:

Whilst I’m happy to add a few new things in here and there, the best result will come from what @muppet3000 is cooking up with the new HACS module. Hopefully this gets us through until that’s ready!

2 Likes

I had a play around from within the app and you are correct, it didn’t like it when I had a charging window set from 9-10am and the discharge from 10am-11am. Once I put it to 10.01am to start it was OK. I will try to send you my amendments in the next few days.