Growatt mode switching via Home Assistant

Hi all, I have my Growatt SPF5000ES inverters hooked into Home Assistant using the Growatt integration and all is working well. What I would like to achieve is the following:
Based on certain sensor values, switch the mode on my inverter from SUB to UTIL and vice versa.
I know one can change the mode via the Growatt server settings by inputting growatt(date) as the passcode but is this even possible via API or webhook and thus from Home Assistant?

If anyone has any information on how I could achieve this from Hassio, please do let me know, thanks.

Hi Stefan,

I want to do the similar setup on SPF 5000 TL. Where I want to charge from Util at certain time of day where our power is very cheap. I can see there are few python libraries that should be able to do it, however I am not a developer. I will talk with some friends of mine and see if anyone can write the code for me. Unless there is someone on this forum that is willing to help. I “sniffed” the api call for switching from “util” to “batt”, the data has this “type” : storage_spf500_ac_output_source and the the param is 0 for battery and 2 for utility, all the param options are easily seen via developer tools in firefox or chrome , so we just need someone keen to developer to code this :wink: . Thanks

I eventually settled for solar-assistant.io that runs on a raspberryPi 4. It has 2x usb B cables going from Pi to each inverter and then a USB rs485 that runs from Pi to master LBSA LIFEPO4 battery with a Cat6 cable joining the Master and Slave batteries via parallel ports. I then use MQTT to send events to and from Hassio.

Hope this helps.

This would work

1 Like

Cheers for the ping. Just note that this is tested for SPH / hybrid inverters. Might need some additional help to add bits for other types. :slight_smile:

Hi Stefan,
If you can find the time, would you post what you are sending via MQTT to switch load/battery/grid modes on your Growatt? I have been trying to figure this out, but don’t seem to be getting anywhere.
Many thanks
James

Greetings Everybody!

Firstly, let me say “hi”, I’m Chris aka ‘muppet3000’ who maintains the Growatt Integration for Home Assistant.

Secondly, sorry for the massive cross-post on all the forum topics with ‘Growatt’ in the title, it was just easier to copy/paste this everywhere.

Thirdly, I didn’t realise how many forum posts there were for Growatt and the Integration!!! I must admit I find the forums very difficult to follow and navigate so I don’t spend much time here.

I mainly wanted to post to draw everyone’s attention to the following info:
1 - I’ve started maintaining the Integration primarily as a ‘custom integration’ which you can find here
2 - There’s a handy Info page for the custom integration here
3 - I will periodically roll up changes from the custom integration into the Core one in Home Assistant but this will not be very regularly
4 - There’s a prioritised list of bugs/feature requests that I’m working on here
5 - There’s a more thorough reasoning for my decision to move this into a custom integration here
6 - One thing that’s missing from the Feature Requests etc. is the addition to configure systems - I’m working on it, but it’s a background task until I have added support for all the different types of systems - Add ideas here if you have thoughts on what you’d like to be able to do.
7 - If you want to log issues or feature requests please do it here - Only there and in the Home Assistant Core repo will I actually see them, like I said I don’t actively monitor the forums, so the official repos are the best places!
8 - Please don’t assume that I’ve read this thread in a huge amount of detail, if feature requests etc. that have been requested in this thread are still relevant, please log them over on the new git repo here and I’ll get them prioritised - PLEASE read through the issues already logged first to check you’re not duplicating requests.

I hope all that makes sense, I’ve marked this thread as ‘watching’ so I’ll get notifications if people respond etc. but getting hold of me via the git repo issues section is the best way.

C

1 Like

Hello, does anyone know if it is possible to control the ac charging amps of the sfp5000es with HA for charging a battery with the spf5000es?

I am planning on buying this inverter with a lifepo4 battery to have it charge from ac power from my solaredge system and power nearby loads. A bit like a solar generator but without panels. I know I know, it’s not that efficient DC to AC to DC to AC but I do not want the NCA battery from solaredge.

If I can automate the charging amps, I can optimize solar charging like I have already done with the Tesla integration and have an extra inverter (after unhooking the optimizers from the de panels) should the solaredge go belly up.

Hi,

Adding on the ad-growatt base by mjdyson, I have improved it to be able to control Export limit and Grid first + a few other improvements, that I think makes automations easier. It’s branched out here:

Bascially everything is now in one Lovelace card with functions to Get and Save all parameters on the card.

I’m using Grott for data collection and then ad-growatt for controlling the inverter. Eg.:

  • Charging battery when cheap power in the night and low forecasted production tomorrow.
  • Stopping export when prices drop below a certain price point
  • Exporting from battery when price is high and forecasted production is high
1 Like

Hi,

I have a dynamic energy contract. Last weekend the prices were -60 euro cent per KWh. This means that every solar KWh I return to the grid costs me 60 euro cent.

Is it possible to switch the inverter off or pause during the time this situation is happening with this solution too?
I have a MOD9000TL3-X

Thanks,
Rien

Yes, use this to set export limit to On, then it all export is stopped on the Growatt inverter:

@KasperHolchKragelund

In installed and configured ad-growatt and all seems okay but I get this error in the logging:

2023-09-20 15:10:56.788067 WARNING get_charge_settings: ------------------------------------------------------------
2023-09-20 15:10:56.788411 WARNING get_charge_settings: Unexpected error in worker for App get_charge_settings:
2023-09-20 15:10:56.788665 WARNING get_charge_settings: Worker Ags: {'id': '10bf8fae5d774c42a19518cafc42369d', 'name': 'get_charge_settings', 'objectid': '9e0a1977ea064bb997bb370b0da1b421', 'type': 'state', 'function': <bound method AD_Growatt.set_charge_settings_export_handler of <growatt_app.AD_Growatt object at 0xffff89a0ebd0>>, 'attribute': 'state', 'entity': 'input_button.adgw_set_charge_settings_button_export', 'new_state': '2023-09-20T13:10:56.524117+00:00', 'old_state': '2023-09-20T12:50:49.429271+00:00', 'pin_app': True, 'pin_thread': 0, 'kwargs': {'__thread_id': 'thread-0'}}
2023-09-20 15:10:56.788899 WARNING get_charge_settings: ------------------------------------------------------------
2023-09-20 15:10:56.790494 WARNING get_charge_settings: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1045, in worker
    funcref(
  File "/config/appdaemon/apps/growatt_app.py", line 104, in set_charge_settings_export_handler
    if self.set_charge_settings_export() == True:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/appdaemon/apps/growatt_app.py", line 94, in set_charge_settings_export
    response = api.update_mix_inverter_setting(device_sn, 'backflow_setting', schedule_settings)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/appdaemon/apps/growattServer.py", line 624, in update_mix_inverter_setting
    data = json.loads(response.content.decode('utf-8'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 7 column 1 (char 13)
2023-09-20 15:10:56.790760 WARNING get_charge_settings: ------------------------------------------------------------

I run the latest versions of all software.

Any clues?

I tried to reproduce the error and also updated my own installation with latest version from GitHub and can’t reproduce the error.

Try replacing the files again with latest version from GitHub and do a soft restart of HA. Make sure the secrets file is updated with the correct info on your inverter.

If I understand you correctly, then everything is working but you get the error? Try testing setting different parameters and saving them and then changing the same parameters in Lovelace card and use the “Load charge settings from server” to see that Lovelace card correctly updates.

What loglevel are you using in appdaemon ?

Hi,

I started getting this error as well.
I think some Python update or maybe HA update broke it. I have updated to version 0.41 which fixed it. Just copy the growatt_app.py file from Github (https://github.com/KasperHolchKragelund/ad-growatt/tree/main/appdaemon/apps)

and it should work again,

Hi @KasperHolchKragelund

I copied the new file and the appdeamon log seems normal (see below)
But I now get error 501 (see screenshot)
Scherm­afbeelding 2023-09-26 om 21.19.42

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting
-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.13.5
 You are running the latest version of this add-on.
 System: Home Assistant OS 10.5  (aarch64 / odroid-n2)
 Home Assistant Core: 2023.9.3
 Home Assistant Supervisor: 2023.09.2
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
Log level is set to INFO
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[21:16:11] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
2023-09-26 21:16:15.694487 INFO AppDaemon: AppDaemon Version 4.4.2 starting
2023-09-26 21:16:15.694744 INFO AppDaemon: Python version is 3.11.5
2023-09-26 21:16:15.694906 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2023-09-26 21:16:15.695050 INFO AppDaemon: Added log: AppDaemon
2023-09-26 21:16:15.695213 INFO AppDaemon: Added log: Error
2023-09-26 21:16:15.695359 INFO AppDaemon: Added log: Access
2023-09-26 21:16:15.695518 INFO AppDaemon: Added log: Diag
2023-09-26 21:16:15.926261 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2023-09-26 21:16:16.180295 INFO HASS: HASS Plugin Initializing
2023-09-26 21:16:16.180537 WARNING HASS: ha_url not found in HASS configuration - module not initialized
2023-09-26 21:16:16.180728 INFO HASS: HASS Plugin initialization complete
2023-09-26 21:16:16.181359 INFO AppDaemon: Initializing HTTP
2023-09-26 21:16:16.181848 INFO AppDaemon: Using 'ws' for event stream
2023-09-26 21:16:16.186624 INFO AppDaemon: Starting API
2023-09-26 21:16:16.189546 INFO AppDaemon: Starting Admin Interface
2023-09-26 21:16:16.190071 INFO AppDaemon: Starting Dashboards
2023-09-26 21:16:16.212416 INFO HASS: Connected to Home Assistant 2023.9.3
2023-09-26 21:16:16.230335 INFO AppDaemon: App 'get_charge_settings' added
2023-09-26 21:16:16.232042 INFO AppDaemon: Found 1 active apps
2023-09-26 21:16:16.232435 INFO AppDaemon: Found 0 inactive apps
2023-09-26 21:16:16.232722 INFO AppDaemon: Found 0 global libraries
2023-09-26 21:16:16.233089 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2023-09-26 21:16:16.234319 INFO AppDaemon: Running on port 5050
2023-09-26 21:16:16.325084 INFO HASS: Evaluating startup conditions
2023-09-26 21:16:16.342295 INFO HASS: Startup condition met: hass state=RUNNING
2023-09-26 21:16:16.342629 INFO HASS: All startup conditions met
2023-09-26 21:16:16.462581 INFO AppDaemon: Got initial state from namespace default
2023-09-26 21:16:17.424230 INFO AppDaemon: New client Admin Client connected
2023-09-26 21:16:18.241876 INFO AppDaemon: Scheduler running in realtime
2023-09-26 21:16:18.247045 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2023-09-26 21:16:18.247510 INFO AppDaemon: Adding /config/appdaemon/apps/ad_group_all to module import path
2023-09-26 21:16:18.251176 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/growatt_app.py
2023-09-26 21:16:18.301974 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/hello.py - ignoring
2023-09-26 21:16:18.303143 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/growattServer.py - ignoring
2023-09-26 21:16:18.304400 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/ad_group_all/group_all.py - ignoring
2023-09-26 21:16:18.305360 INFO AppDaemon: Loading app get_charge_settings using class AD_Growatt from module growatt_app
2023-09-26 21:16:18.307735 INFO AppDaemon: Calling initialize() for get_charge_settings
2023-09-26 21:16:18.316724 INFO AppDaemon: App initialization complete
2023-09-26 21:16:18.429926 INFO AppDaemon: New client Admin Client connected

Seems like Growatt servers are down today.
Or they changed the API.
I’ll try to figure out what’s wrong.
My installation also started reporting 501 errors today.

Just an update. Seems like Growatt found a way to block API calls and I have so far not found a way around the block. Turns out the small fix I did from version 0.4 to 0.41 did not change anything, just movbed the error from the log to the UI.
The cause of the problem is the blocking from Growatt servers.

The block can easily be seen here: https://server-api.growatt.com/

Very strange that Growatt is trying so hard to make their product unusable for their customers. Will keep investigating as it must be affecting every Growatt API integration out there, except for Grott.

1 Like

Hi, is it possible add option “Discharge Stopped Soc” from section Load first?
obrazek

Thanks Jan