Skip to content

Growatt Binding ​

This binding supports the integration of Growatt solar inverters.

It depends on the independent Grott proxy server application. This intercepts the logging data that the Growatt inverter data logger normally sends directly to the Growatt cloud server. It sends the original (encoded) data onwards to the cloud server (so the cloud server will not notice anything different). But it also sends a (decoded) copy to openHAB as well.

Supported Things ​

The binding supports two types of things:

  • bridge: The bridge is the interface to the Grott application; it receives the data from all inverters.
  • inverter: The inverter thing contains channels which are updated with solar production and consumption data.

Discovery ​

There is no automatic discovery of the bridge. However if a bridge exists and it receives inverter data, then a matching inverter thing is created in the Inbox.

Thing Configuration ​

The bridge thing allows configuration of the user credentials, which are only required if you want to send inverter commands via the Growatt cloud server:

NameTypeDescriptionAdvancedRequired
userNametextUser name for the Growatt Shine app. Only needed if using Rule Actionsyesno
passwordtextPassword for the Growatt Shine app. Only needed if using Rule Actionsyesno

The inverter thing requires configuration of its serial number, i.e., deviceId:

NameTypeDescriptionRequired
deviceIdtextDevice serial number or id as configured in the Growatt cloud and the Grott application.yes

Channels ​

The bridge thing has no channels.

The inverter thing supports many possible channels relating to solar generation and consumption. All channels are read-only. Depending on the inverter model, and its configuration, not all of the channels will be present. The list of all possible channels is as follows:

ChannelTypeDescriptionAdvanced
system-statusNumber:DimensionlessInverter status code.
pv1-voltageNumber:ElectricPotentialDC voltage from solar panel string #1.yes
pv2-voltageNumber:ElectricPotentialDC voltage from solar panel string #2.yes
pv1-currentNumber:ElectricCurrentDC current from solar panel string #1.yes
pv2-currentNumber:ElectricCurrentDC current from solar panel string #2.yes
pv-powerNumber:PowerTotal DC solar input power.
pv1-powerNumber:PowerDC power from solar panel string #1.yes
pv2-powerNumber:PowerDC power from solar panel string #2.yes
grid-frequencyNumber:FrequencyFrequency of the grid.yes
grid-voltage-rNumber:ElectricPotentialVoltage of the grid (phase #R).
grid-voltage-sNumber:ElectricPotentialVoltage of the grid phase #S.yes
grid-voltage-tNumber:ElectricPotentialVoltage of the grid phase #T.yes
grid-voltage-rsNumber:ElectricPotentialVoltage of the grid phases #RS.yes
grid-voltage-stNumber:ElectricPotentialVoltage of the grid phases #ST.yes
grid-voltage-trNumber:ElectricPotentialVoltage of the grid phases #TR.yes
inverter-currentNumber:ElectricCurrentAC current from inverter.yes
inverter-current-rNumber:ElectricCurrentAC current from inverter (phase #R).yes
inverter-current-sNumber:ElectricCurrentAC current from inverter phase #S.yes
inverter-current-tNumber:ElectricCurrentAC current from inverter phase #T.yes
inverter-powerNumber:PowerTotal AC output power from inverter.
inverter-power-rNumber:PowerAC power from inverter (phase #R).
inverter-power-sNumber:PowerAC power from inverter phase #S.yes
inverter-power-tNumber:PowerAC power from inverter phase #T.yes
inverter-vaNumber:PowerAC VA from inverter.yes
export-powerNumber:PowerPower exported to grid.
export-power-rNumber:PowerPower exported to grid phase #R.yes
export-power-sNumber:PowerPower exported to grid phase #S.yes
export-power-tNumber:PowerPower exported to grid phase #T.yes
import-powerNumber:PowerPower imported from grid.
import-power-rNumber:PowerPower imported from grid phase #R.yes
import-power-sNumber:PowerPower imported from grid phase #S.yes
import-power-tNumber:PowerPower imported from grid phase #T.yes
load-powerNumber:PowerPower supplied to load.
load-power-rNumber:PowerPower supplied to load phase #R.yes
load-power-sNumber:PowerPower supplied to load phase #S.yes
load-power-tNumber:PowerPower supplied to load phase #T.yes
charge-powerNumber:PowerBattery charge power.
charge-currentNumber:ElectricCurrentBattery charge current.yes
discharge-powerNumber:PowerBattery discharge power.
discharge-vaNumber:PowerBattery discharge VA.yes
pv-energy-todayNumber:EnergyDC energy collected by solar panels today.
pv1-energy-todayNumber:EnergyDC energy collected by solar panels string #1 today.yes
pv2-energy-todayNumber:EnergyDC energy collected by solar panels string #2 today.yes
pv-energy-totalNumber:EnergyTotal DC energy collected by solar panels.
pv1-energy-totalNumber:EnergyTotal DC energy collected by solar panels string #1.yes
pv2-energy-totalNumber:EnergyTotal DC energy collected by solar panels string #2.yes
inverter-energy-todayNumber:EnergyAC energy produced by inverter today.
inverter-energy-totalNumber:EnergyTotal AC energy produced by inverter.
export-energy-todayNumber:EnergyEnergy exported today.
export-energy-totalNumber:EnergyTotal energy exported.
import-energy-todayNumber:EnergyEnergy imported today.
import-energy-totalNumber:EnergyTotal energy imported.
load-energy-todayNumber:EnergyEnergy supplied to load today.
load-energy-totalNumber:EnergyTotal energy supplied to load.
import-charge-energy-todayNumber:EnergyEnergy imported to charge battery today.
import-charge-energy-totalNumber:EnergyTotal energy imported to charge battery.
inverter-charge-energy-todayNumber:EnergyInverter energy to charge battery today.
inverter-charge-energy-totalNumber:EnergyTotal inverter energy to charge battery.
discharge-energy-todayNumber:EnergyEnergy consumed from battery.
discharge-energy-totalNumber:EnergyTotal energy consumed from battery.
total-work-timeNumber:TimeTotal work time of the system.yes
p-bus-voltageNumber:ElectricPotentialP Bus voltage.yes
n-bus-voltageNumber:ElectricPotentialN Bus voltage.yes
sp-bus-voltageNumber:ElectricPotentialSP Bus voltage.yes
pv-temperatureNumber:TemperatureTemperature of the solar panels (string #1).yes
pv-ipm-temperatureNumber:TemperatureTemperature of the IPM.yes
pv-boost-temperatureNumber:TemperatureBoost temperature.yes
temperature-4Number:TemperatureTemperature #4.yes
pv2-temperatureNumber:TemperatureTemperature of the solar panels (string #2).yes
battery-typeNumber:DimensionlessType code of the battery.yes
battery-temperatureNumber:TemperatureBattery temperature.yes
battery-voltageNumber:ElectricPotentialBattery voltage.yes
battery-voltage2Number:ElectricPotentialBattery voltage #2.yes
battery-displayNumber:DimensionlessBattery display code.yes
battery-socNumber:DimensionlessBattery State of Charge percent.yes
battery-discharge-vaNumber:PowerBattery discharging reactive power.yes
battery-discharge-wattNumber:PowerBattery discharging power.yes
battery-discharge-energy-todayNumber:EnergyBattery discharge energy today.yes
battery-discharge-energy-totalNumber:EnergyTotal battery discharge energy.yes
system-fault-0Number:DimensionlessSystem fault code #0.yes
system-fault-1Number:DimensionlessSystem fault code #1.yes
system-fault-2Number:DimensionlessSystem fault code #2.yes
system-fault-3Number:DimensionlessSystem fault code #3.yes
system-fault-4Number:DimensionlessSystem fault code #4.yes
system-fault-5Number:DimensionlessSystem fault code #5.yes
system-fault-6Number:DimensionlessSystem fault code #6.yes
system-fault-7Number:DimensionlessSystem fault code #7.yes
system-work-modeNumber:DimensionlessSystem work mode code.yes
sp-display-statusNumber:DimensionlessSolar panel display status code.yes
constant-power-okNumber:DimensionlessConstant power OK code.yes
load-percentNumber:DimensionlessPercent of full load.yes
racNumber:PowerReactive 'power' (var).yes
erac-todayNumber:EnergyReactive 'energy' today (kvarh).yes
erac-totalNumber:EnergyTotal reactive 'energy' (kvarh).yes
charge-vaNumber:PowerCharging reactive power.yes
inverter-clock-offsetNumber:TimeTime offset of inverter clock vs. OH system clock.yes
inverter-fan-speedNumber:DimensionlessInverter fan speed percent.yes
pv3-voltageNumber:ElectricPotentialVoltage from solar panel string #3.yes
pv3-currentNumber:ElectricCurrentCurrent from solar panel string #3.yes
pv3-powerNumber:PowerPower from solar panel string #3.yes
pv4-voltageNumber:ElectricPotentialVoltage from solar panel string #4.yes
pv4-currentNumber:ElectricCurrentCurrent from solar panel string #4.yes
pv4-powerNumber:PowerPower from solar panel string #4.yes
pv3-energy-todayNumber:EnergySolar DC energy collected by string #3 today.yes
pv3-energy-totalNumber:EnergyTotal solar DC energy collected by string #3.yes
power-factorNumber:PercentElectrical power factoryes
eps-voltage-rNumber:ElectricPotentialEmergency Power Supply voltage (phase #R).yes
eps-voltage-sNumber:ElectricPotentialEmergency Power Supply voltage (phase #S).yes
eps-voltage-tNumber:ElectricPotentialEmergency Power Supply voltage (phase #T).yes
eps-current-rNumber:ElectricCurrentEmergency Power Supply current (phase #R).yes
eps-current-sNumber:ElectricCurrentEmergency Power Supply current (phase #S).yes
eps-current-tNumber:ElectricCurrentEmergency Power Supply current (phase #T).yes
eps-powerNumber:PowerTotal Emergency Power Supply power.yes
eps-power-rNumber:PowerEmergency Power Supply power (phase #R).yes
eps-power-sNumber:PowerEmergency Power Supply power (phase #S).yes
eps-power-tNumber:PowerEmergency Power Supply power (phase #T).yes

Rule Actions ​

This binding includes rule actions, which allow you to setup programs for battery charging and discharging. Each inverter thing has a separate actions instance, which can be retrieved as follows.

rules
val growattActions = getActions("growatt", "growatt:inverter:home:sph")

Where the first parameter must always be growatt and the second must be the full inverter thing UID. Once the action instance has been retrieved, you can invoke the following method:

java
growattActions.setupBatteryProgram(int programMode, @Nullable Integer powerLevel, @Nullable Integer stopSOC, @Nullable Boolean enableAcCharging, @Nullable String startTime, @Nullable String stopTime, @Nullable Boolean enableProgram)

The meaning of the method parameters is as follows:

ParameterDescription
programModeThe program mode to set i.e. 'Load First' (0), 'Battery First' (1), 'Grid First' (2).
powerLevel2)The percentage rate of battery (dis-)charge e.g. 100 - in 'Battery First' mode => charge power, otherwise => discharge power.
stopSOC2)The battery SOC (state of charge) percentage when the program shall stop e.g. 20 - in 'Battery First' mode => max. SOC, otherwise => min. SOC.
enableAcCharging2)Allow the battery to be charged from the AC mains supply e.g. true, false.
startTime1,2)String representation of the local time when the program time segment shall start e.g. "00:15"
stopTime1,2)String representation of the local time when the program time segment shall stop e.g. "06:45"
enableProgram1,2)Enable / disable the program time segment e.g. true, false

Notes:

-1) WARNING inverters have different program time segment's for each programMode. To prevent unexpected results do not overlap the time segment's.

-2) Depending on inverter type and programMode certain parameters may accept 'null' values. The 'mix', 'sph' and 'spa' types set the battery program in a single command, so all parameters - except enableAcCharging - must be non- 'null'. By contrast 'tlx' types set the battery program in up to four partial commands, and you may pass 'null' parameters in order to omit a partial command. The permission for passing 'null' parameters, and the effect of such 'null' parameters, is shown in detail in the table below:

ParameterPermission for.. / effect of.. passing a 'null' parameter
programModeShall not be 'null' under any circumstance!
powerLevelMay be 'null' on 'tlx' inverters whereby the prior programMode / powerLevel continues to apply.
stopSOCMay be 'null' on 'tlx' inverters whereby the prior programMode / stopSOC continues to apply.
enableAcChargingIf 'null' the prior enableAcCharging (if any) continues to apply. Shall not be 'null' on 'mix' inverter 'Battery First' program.
startTime, stopTime, enableProgramMay be 'null' on 'tlx' inverters whereby the prior programMode / time segment continues to apply - note all 'null' resp. non-'null'.

Example program to charge battery during night-time low tariff time window ​

The following is an example program to charge the battery during a night-time low tariff period, and depending on the forecast solar energy for the coming day.

rules
// solar power constants
val Integer programMode = 1 // 0 = Load First, 1 = Battery First, 2 = Grid First
val Integer powerLevel = 23 // percent
val batteryFull = 6500.0 // Wh
val batteryMin = 500.0 // Wh
val daylightConsumption = 10000.0 // Wh
val offPeakConsumption = 2000.0 // Wh
val maximumSOC = 100.0 // percent
val minimumSOC = 10.0 // percent
val maxChargingPower = 4000.0 // W
val offPeakEndMinute = 420 // 07:00
val offPeakStartMinute = 20 // 00:20

..

rule "Setup Solar Battery Charging Program"
when
    Time cron "0 10 0 ? * * *"
then
    val growattActions = getActions("growatt", "growatt:inverter:home:ABCD1234") // thing UID
    if (growattActions === null) {
        logWarn("Rules", "growattActions is null")
        return
    }

    // variable algorithm parameters
    var Integer startMinute = offPeakStartMinute
    var Boolean enableProgram = true
    var Boolean enableAcCharging = true

    // calculate required stop SOC based on weather forecast
    val Double solarForecast = (Solar_Forecast_Energy_Today_Full.state as QuantityType<Energy>).toUnit("Wh").doubleValue()
    var Double targetSOC = (100.0 * (batteryMin + daylightConsumption - solarForecast)) / batteryFull
    if (targetSOC > maximumSOC) {
        targetSOC = maximumSOC
    }

    // calculate notional SOC at end of off peak period
    var Double morningSOC = ((Battery_SOC_Level.state as QuantityType<Dimensionless>).toUnit("one").doubleValue() - (offPeakConsumption / batteryFull)) * 100.0
    if (morningSOC < minimumSOC) {
        morningSOC = minimumSOC
    }

    // calculate charging start time (if any)
    if (targetSOC > morningSOC) {
        startMinute = (offPeakEndMinute - (60.0 * (targetSOC - morningSOC) * batteryFull / (powerLevel * maxChargingPower))).intValue()
        if (startMinute < offPeakStartMinute) {
            startMinute = offPeakStartMinute
        }
    } else {
        enableProgram = false
        enableAcCharging = false
        targetSOC = minimumSOC
    }

    // convert times to strings
    val String startTime = String.format("%02d:%02d", startMinute / 60, startMinute % 60);
    val String stopTime = String.format("%02d:%02d", offPeakEndMinute / 60, offPeakEndMinute % 60);

    // convert to integer percent
    val Integer stopSOC = targetSOC.intValue()

    logInfo("Rules", "Setup Charging Program(morningSOC=" + morningSOC + "%, solarForecast=" + solarForecast + "Wh, programMode=" + programMode + ", powerLevel=" + powerLevel +
        "%, stopSOC=" + stopSOC + "%, enableCharging=" + enableAcCharging + ", startTime=" + startTime + ", stopTime=" + stopTime + ", enableProgram=" + enableProgram +")")
    growattActions.setupBatteryProgram(programMode, powerLevel, stopSOC, enableAcCharging, startTime, stopTime, enableProgram)
end

Example program to charge battery prior to an extra high tariff window in the day ​

The following is an example program to charge the battery in preparation to avoid importing energy during a coming extra high tariff time window.

rules
// solar power constants
var pauseProgramLastSetupDate

..

rule "Setup Solar Power Pause Program"
when
    Time cron "59 0 8-22 ? * * *" or
    Item Power_Pause_Program_Start changed
then
    val programSetupDate = now.toLocalDate()
    if (programSetupDate.equals(pauseProgramLastSetupDate)) {
        logInfo("Rules", "Power Pause program already setup for " + programSetupDate)
        return
    }

    val pauseStartState = Power_Pause_Program_Start.state
    if (pauseStartState == NULL || pauseStartState == UNDEF) {
        logWarn("Rules", "Power_Pause_Program_Start state is null or undefined")
        return
    }

    var pauseStartDateTime = (pauseStartState as DateTimeType).getZonedDateTime()
    if (pauseStartDateTime.getHour() < 8) {
        logWarn("Rules", "Power Pause program shall not start before 08:00h => " + pauseStartDateTime)
        return
    }

    val programDuration = Duration.between(now, pauseStartDateTime)
    if (programDuration.isNegative() || programDuration.toDays() > 0) {
        logInfo("Rules", "Power Pause program date is not today => " + pauseStartDateTime)
        return
    }
    if (programDuration.toHours() < 1) {
        logWarn("Rules", "Power Pause program lead time is too short => " + pauseStartDateTime)
        return
    }

    // setup program to start late and end early in case inverter clock not in synch
    val delta = 600
    pauseStartDateTime = pauseStartDateTime.minusSeconds(delta)
    val chargeStartDateTime = pauseStartDateTime.minusSeconds(programDuration.toSeconds()).plusSeconds(2 * delta)
    if (chargeStartDateTime.isBefore(now)) {
        logWarn("Rules", "Power Pause program start time is in the past")
        return
    }

    val formatter = DateTimeFormatter.ofPattern("HH:mm");
    val String stopTime = pauseStartDateTime.format(formatter)
    val String startTime = chargeStartDateTime.format(formatter)

    val socState = Battery_SOC_Level.state
    if (socState == NULL || socState == UNDEF) {
        logWarn("Rules", "Battery_SOC_Level is null or undefined")
        return
    }
    val currentSOC = (socState as Number)

    var targetPowerLevel = ((maximumSOC - currentSOC) * batteryFull) / (maxChargingPower * (programDurationSeconds / 3600.0))
    if (targetPowerLevel < 23.0) {
        targetPowerLevel = 23.0
    } else if (targetPowerLevel > 100.0) {
        targetPowerLevel = 100.0
    }
    val Integer powerLevel = targetPowerLevel.intValue()

    val Integer programMode = 1 // 0 = Load First, 1 = Battery First, 2 = Grid First
    val Boolean enableAcCharging = true
    val Boolean enableProgram = true
    val Integer stopSOC = maximumSOC.intValue()

    val growattActions = getActions("growatt", "growatt:inverter:home:ABCD1234") // thing UID
    if (growattActions === null) {
        logWarn("Rules", "growattActions is null")
        return
    }

    pauseProgramLastSetupDate = programSetupDate
    logInfo("Rules", "Setup Solar Power Pause Program(programMode=" + programMode + ", powerLevel=" + powerLevel + "%, stopSOC=" + stopSOC + "%, enableCharging=" +
        enableAcCharging + ", startTime=" + startTime + ", stopTime=" + stopTime + ", enableProgram=" + enableProgram +")")
    growattActions.setupBatteryProgram(programMode, powerLevel, stopSOC, enableAcCharging, startTime, stopTime, enableProgram)
end

Full Example ​

Example .things file ​

dsl
Bridge growatt:bridge:home "Growatt Bridge" [userName="USERNAME", password="PASSWORD"] {
    Thing inverter sph "Growatt SPH Inverter" [deviceId="INVERTERID"]
}

Example .items file ​

dsl
Number:ElectricPotential Solar_String1_Voltage "Solar String #1 PV Voltage" {channel="growatt:inverter:home:sph:pv1-voltage"}
Number:ElectricCurrent Solar_String1_Current "Solar String #1 PV Current" {channel="growatt:inverter:home:sph:pv1-current"}
Number:Power Solar_String1_Power "Solar String #1 PV Power" {channel="growatt:inverter:home:sph:pv1-power"}
Number:Energy Solar_Output_Energy "Solar Output Energy Total" {channel="growatt:inverter:home:sph:pv-energy-total"}

Example using a transform profile to invert an item value:

dsl
// charge item with positive value
Number:Power Charge_Power "Charge Power [%.0f W]" <energy> {channel="growatt:inverter:home:sph:charge-power"}

// discharge item with negative value
Number:Power Discharge_Power "Discharge Power [%.0f W]" <energy> {channel="growatt:inverter:home:sph:discharge-power" [ profile="transform:JS", toItemScript="| Quantity(input).multiply(-1).toString();" ] }

Grott Application Installation and Setup ​

The Grott application acts as a proxy server between your Growatt inverter and the Growatt cloud server. It intercepts data packets between the inverter data logger and the cloud server, and it passes a copy of the intercepted data also to openHAB.

If you have an openHABian system then you can install it automatically via the openHABian configuration UI. See openHABian Installation of Grott below. Otherwise see Manual Installation of Grott below.

After installing Grott you MUST change your Growatt data logger configuration to send its data to the Grott proxy server instead of to the Growatt server. See Route Growatt Inverter Logging via Grott Proxy below.

NOTE: make sure that the Grott application is FULLY OPERATIONAL for your inverter BEFORE you create any things in openHAB! Otherwise the binding might create a wrong (or even empty) list of channels for the inverter thing. (Yet if you do make that mistake you can rectify it by deleting and recreating the thing).

You should configure the Grott application via its grott.ini file. Configure Grott to match your inverter according to the instructions.

openHABian Installation of Grott ​

On an openHABian system, you can install and upgrade the Grott proxy server application via the sudo openhabian-config command. Select the menu option 2F.

Manual Installation of Grott ​

You can install the Grott application either on the same computer as openHAB or on another. The following assumes you will be running the Grott application on the same computer as openHAB is running on.

Install Python ​

If Python is not already installed on your computer, then install it first. And install the following additional necessary python packages:

bash
sudo pip3 install paho-mqtt
sudo pip3 install requests

Install Grott ​

First install the Grott application and the Grott application extension files in a Grott specific home folder. Note that Grott requires the grottext.py application extension in addition to the standard application files. The installation is as follows:

  • Create a 'home' sub-folder for Grott e.g. /home/<username>/grott/.
  • Copy grott.py, grottconf.py, grottdata.py, grottproxy.py, grottsniffer.py, grottserver.py to the home folder.
  • Copy grottext.py application extension to the home folder.
  • Copy grott.ini configuration file to the home folder.
  • Modify grott.ini to run in proxy mode; not in compatibility mode; show your inverter type; not run MQTT; not run PVOutput; enable the grottext extension; and set the openHAB /growatt servlet url.

A suggested Grott configuration for openHAB is as follows:

ini
[Generic]
mode = proxy
compat = False
invtype = sph // your inverter type

[MQTT]
nomqtt = True // disable mqtt

[PVOutput]
pvoutput = False // disable pvoutput

[extension] // enable the 'grottext' extension
extension = True
extname = grottext
extvar = {"url": "http://127.0.0.1:8080/growatt"} // or ip address of openHAB (if remote)

Start Grott as a Service ​

Finally you should set your computer to starts the Grott application automatically as a service when your computer starts. For Windows see wiki: https://github.com/johanmeijer/grott/wiki/Grott-as-a-service-(Windows) For Linux see wiki: https://github.com/johanmeijer/grott/wiki/Grott-as-a-service-(Linux) The service configuration for Linux is summarised below:

  • Copy the grott.service file to the /etc/systemd/system/ folder
  • Modify grott.service to enter your user name; the Grott settings; the path to Python; and the path to the Grott application:
ini
[Service]
SyslogIdentifier=grott
User=<username>  // your username
WorkingDirectory=/home/<username>/grott/ // your home grott folder
ExecStart=-/usr/bin/python3 -u /home/<username>/grott/grott.py -v // ditto

And finally enable the Grott service:

bash
sudo systemctl enable grott

Route Growatt Inverter Logging via Grott Proxy ​

Normally the Growatt inverter sends its logging data directly to port 5279 on the Growatt server at server.growatt.com (ip=47.91.67.66) on the cloud. Grott is a proxy server that interposes itself between the inverter and the cloud server. i.e. it receives the inverter logging data and forwards it unchanged to the cloud server.

WARNING: make sure that Grott is running on a computer with a STATIC IP ADDRESS (and note this safely)! Otherwise if the computer changes its ip address dynamically, it can no longer intercept the inverter data. This means YOU WILL NO LONGER BE ABLE TO RESET THE INVERTER to its original settings!

You need to use the Growatt App to tell the inverter to send its logging data to the Grott proxy instead of to the cloud. See wiki: https://github.com/johanmeijer/grott/wiki/Rerouting-Growatt-Wifi-TCPIP-data-via-your-Grott-Server for more information.