Skip to content
mjdyson edited this page Jan 7, 2023 · 15 revisions

Before you start

Read this guide through and understand what's going on.

If in doubt, read it again. Ask questions in the Community. Hopefully other people can lend a hand.

If still in doubt. Consider asking a friend, or stopping before you get too deep :)

Disclaimer

The developers & maintainers of this guide accept no responsibility for any damage, problems or issues that arise with your Growatt systems as a result of its use.

This example references functions from an open source library that allows you to modify the configuration of your plant & inverter, which carries the ability to set values outside of normal operating parameters, therefore, settings should only be modified if you understand the consequences.

To the best of our knowledge only the settings functions perform modifications to your system and all other operations are read only. Regardless of the operation:

⚠️ The library is used entirely at your own risk.

Remarks

  • This is a TEMPORARY approach to controlling your inverter. The API is frequently changing and may break at any point.
  • Be prepared to tinker - this is just a guide to get some basic commands sent and received from the growatt servers
  • Getting all of this to work is complicated and may not be applicable to your inverter. The inverter used in these examples is a hybrid (SPH or mix) inverter. There are many parts to configure
  • The GrowattServer code has been lightly modified to allow settings to be read from the mix inverters
    • Added a read batter settings function
    • Adjusted the user agent to create a random ID
  • In the future, this functionality may be built into the HA Growatt integration. The dev is aware, but it will require some significant work.

Basic Operation

The AppDaemon app works by emulating the functionality provided by an iOS / Android app in conjunction with the Shine Server capability. The Shine Server will do the communication with your plant and ensure that all the modes are switched when requested. If the server is down, your functions will fail.

image

The AppDaemon app has 2 basic functions:

  1. Get Current Values on the server (for displaying in HA)
  2. Set New Values on the server (for the new control)

💡 Tip: It would be useful to make a plan for how you want these modes to work. Do some testing without this app to work out what you need.

With this in mind we need to understand the basic modes provided by the Shine Server so that we can make the switches as we need.

Mix Inverter Settings

By default the mix inverter will run in "Load First" mode, meaning that the plant will output to your local demands, dynamically changing between solar and battery as required.

💡 Tip: The server does not have a direct mode switching function. Instead, it uses "Time Slots" to schedule mode switching between given time periods. With some planning ahead, you can make this act like a mode switch.

Grid First (Grid Export Priority):

In this mode, your plant will output to the grid at the power rate specified. Once your battery hits “Discharge Stopped SoC” it will no longer output from the batteries. This might be useful if you get paid a premium during certain periods.

Battery First (Battery Charging Priority):

Your plant will charge batteries at the “Charge Power Rate” specified. If you select the “Ac Charge” option, it will charge the batteries from the grid during this period. This might be useful for cheaper off-peak charging periods.

Load First (Default Mode):

If no other schedules are active, this is the mode the plant will be in. The plant will consume power from Batteries until they reach the “Discharge Stopped SoC” – at this point it will draw from the grid.

Setup Overview

⚠️ Important: Make sure AppDaemon is working properly within your HA environment. It may also help to have Visual Studio Code add-on installed too, so you can easily create and edit the files.

To set up the example App, you need to:

  1. Create Sensors in HA to store the current values from the Growatt Server once you've retrieved them
  2. Create UI helpers in HA to store the desired values you want to set the server to. Note: this is different to those in point 1 and will not do anything until you press the "Update the Server" button.

Option: Here is where you may want to subsitute a different sensor that contains the values you want to set the server to. For example, if you're relying on another plugin to get your off-peak schedule.

  1. Create your username / password as secrets in secrets.yaml (if you dont have this already, make it happen https://www.home-assistant.io/docs/configuration/secrets/
  2. Add the AppDaemon app, checking that it registers
  3. Test, test, test... and test again
  4. Double check your Growatt account for values that have been applied as you intended.

1) Create HA Sensors

This step is optional.

Whilst the Growatt integration does this for you, you may find it useful to use the AppDaemon app to pull the latest values from the server too. I found it useful as a way to check that the app was working properly and the server is responding as expected.

If you dont do this step via a sensors file, AppDaemon can do this for you - however, the sensors will not persist between HA reboots. Any dashboards you create will show errors until you re-run the getValues function again from the app.

a) Via sensors.yaml file

Todo

b) Via AppDaemon

Todo

This already happens in the example script. The following line of code, creates a sensor with ID = sensor.battery_first_time_slot_1_start and sets the state to a response from the server.

self.set_state("sensor.battery_first_time_slot_1_start", state = response['obj']['mixBean']['forcedChargeTimeStart1'], attributes = {"friendly_name": "Charge Time 1 Start"})

2) Create HA Helpers and Scripts

Todo

image image image

A script named growatt_reset_time_to_offpeak (yaml is below). This script was only used to allow me to quickly get back to my off-peak window.

image

alias: growatt_reset_time_to_offpeak
sequence:
  - service: input_datetime.set_datetime
    data:
      time: "00:30:00"
    target:
      entity_id: input_datetime.growatt_start_time
  - service: input_datetime.set_datetime
    data:
      time: "04:30:00"
    target:
      entity_id: input_datetime.growatt_end_time
mode: single
icon: mdi:recycle-variant

3) Create secrets.yaml Entries

Todo

image

4) Create AppDaemon files

Todo

image

This is a screenshot of the AppDaemon logs. Notice there are no errors and the app initialization completes. If anyone knows how to get rid of the warning about app descriptions, please let me know. image

5) Setup a GUI and Test

Todo

image

Card 1

entities:
  - entity: input_button.house_battery_get_charge_settings_button
    name: Get Latest Server Settings
  - type: divider
  - entity: sensor.battery_first_ac_charge_enabled
    name: Battery First - Ac Charge
  - entity: sensor.battery_first_charge_stopped_soc
    name: Battery First - Charge Stopped SoC
  - entity: sensor.battery_first_time_slot_1_start
    name: Battery First - Time Slot 1 (Start)
  - entity: sensor.battery_first_time_slot_1_stop
    name: Battery First - Time Slot 1 (End)
  - entity: sensor.battery_first_ac_charge_enabled
    name: Battery First - Time Slot 1 Enabled
  - type: divider
  - entity: input_button.reset_time
    name: Clear Local Sensor Values
title: Get Values from Server

Card 2

entities:
  - entity: input_select.growatt_charge_final_soc
    name: SoC Charge Max
  - entity: input_boolean.growatt_force_charge_on
    name: Ac Charge
  - entity: input_datetime.growatt_start_time
    name: Time Slot 1 (Start)
  - entity: input_datetime.growatt_end_time
    name: Time Slot 1 (End)
  - type: divider
  - entity: input_button.house_battery_set_charge_settings_button
    name: Update the Server
  - entity: script.growatt_reset_time_off_peak
    name: Reset Time to Test Values
title: Update Server with Values

6) Check your Growatt account

Todo