Growatt Inverter Mode Switch

I might tweak my fork to bring across device IDs into HA and store those in a non-volatile sensor value for your plants.

The interaction with growattserver will largely be the same but you’d need to let the updater know which inverter you want to adjust.

1 Like

Sign me up if i need to test… for now i have moved my MID to another plant… so the ID wont change during on/off.

Hello all,

For those feeling adventurous… I’ve created a test branch on github. I’ll try my best to keep everything in there working. Just keep a copy of anything you’ve got working! You’ve been warned :slight_smile:

See the Testing page on the wiki - Testing · mjdyson/ad-growatt Wiki (github.com)

First change is to simplify the configuration a little more. There’s no new functionality this time. All of the configuration aspects (script, sensors, inputs / helpers) are now provided in a single package file. It will break your GUI until you change it to read from the new sensors / helpers.

Any feedback is welcomed.

2 Likes

Hello @affer - I’ve got something for you to test with multiple device options. See another new branch linked below. I will merge this in with the other Test branch if it seems to work ok.

I’ll advise you take a backup of your working code before testing this - I’ve tested it here, but I only have one device.

Also, it might be worth getting the first Test up and running first as this changed how some of the entity ids were created / configured.

Testing Multi Device Plants · mjdyson/ad-growatt Wiki (github.com)

I will take a look at it asap :slight_smile: looking forward to it :smiley: Btw,., been running flawlessly the last couple of days… i love it :smiley:

Hi Guys,

I’m making this blanket post in loads of different locations, but just so you’re in the loop, I’ve just made a big post over here: Growatt Integration - Roadmap (see the original post and my latest comment) about moving the integration out of home assistant core and into HACS.

If some of you are still interested in using it, please take a look at the new incarnation of the integration (it’s currently identical to the version available in Core but will diverge in the next few releases), then please go ahead.

If you can’t be bothered to read the other post, just take a look here: GitHub - muppet3000/homeassistant-growatt_server_api: Home Assistant Integration for Growatt - Replacement for the original growatt_server integration that used to be part of the core Home Assistant repository

2 Likes

Hi mark

At last i got some time to update. Update to test branch went fine (and working) great update, makes set up a lot easier :+1:t2:

the branch with multi device i had some troubles… the first error was kind of my fault. i had an plant with no inverter in, deleting this plant could get the next plant to load… But i only get one plant (i have two plants, both with SPH inverters in it)

Screenshot 2023-01-13 at 20.34.08

We should be thankful for some great work from the community for the new setup file. It’s made things very simple.

Currently I only have an iterator each ‘device’ within a single ‘plant’. Without multiple inverters it’s hard to test. However, I think I’ve got a solution - I’ll try to code up something tomorrow and get it out for testing. If this doesnt work, I might need to get some more data.somehow. A long day moving earth around in the garden has wiped me out :laughing:

One thing I’ve noticed, calls to the server time out a lot. Traceroute shows it’s not getting to the end server after 10+ hops… rather than the server calls being blocked. As a future update, I’d like to build a timestamp / response code from the server back into the UI. Maybe even a request timestamp too. Watch this space :slight_smile:

1 Like

@affer - new code on multi-device branch if you’d like to try. It should iterate through all plants to get all devices, Dropdown box still needs to be refreshed to be selectable. Weird interaction between AppDaemon and HA i need to see if it can be resolved.

1 Like

getting settings works :smiley: and both plants are beeing listed now :smiley: i can read and write settings as expected :+1:t2:

Nice! I’d say it’s time to merge multi plant into test.

Once I’ve updated the docs I’ll merge into main. Thank you for testing :slight_smile:

1 Like

No problem. with your and others input, and my nodered scripting i got a really good integration working with charging batteries overnight at cheapest price and discharging at high tariff. :slight_smile: ofcause work in progress… but this is really going somewhere :smiley:

I guys, I’ve been watching this one from the sidelines what with all of the stuff I’ve been doing to move the Growatt Integration into HACS I’ve had my hands full.

I’ve still got some other bits I need to wrap up on that front and also add the support for the systems that are currently missing, but I’d love to try and integrate what you’ve been doing in to the HA Integration.

I already have an email chain going with @mjdyson from before Christmas so I’ll resurrect that and see what we can do, especially if there’s stuff to feed back into the core python library.

Keep doing what you’re doing! Just wanted to check in and let you know I’m still paying attention.

2 Likes

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…