Skip to content

How to add the total of two solar inverters in Domoticz

I have two inverters — a SolarEdge and a GroWatt — and I want to combine the gross kWh output of both in one graph i.e. one Domoticz device.

There are multiple ways to do this. Currently I have two different Domoticz devices that add the SolarEdge (via API) and GroWatt (via this script) output together. One device is called SumGenkWh and one called Total Today. They both give the same result, but the way of calculating is a bit different.

10.6 kWh for both

I spent way too long figuring this out, so this blog is for posterity.

I actually found three ways to achieve this (above are the result of two), all solutions involve a DzVents script.

The Domoticz forum helped me in the right direction but some details were missing.

Method 1 Create a custom sensor

This is the most straightforward. And I found this on the Domoticz forum. It is just a generic custom sensor. It just acts like a dumb counter. If that is all you need, great!

This is the DzVents script, to add the values to the sensor.

return {
      on = { 
        timer = {
           'every 5 minutes'            
        },
    }, 
    execute = function(domoticz, device, timer)
	-- Replace between () the idx or 'name' of your solar panel devices or put -- in front of it if you don't use it
    	local vandaagKwhzon = domoticz.devices(509).counterToday
    	local vandaagKwhzon2 = domoticz.devices(514).counterToday 

 	-- Create a customsensor with Kwh as variable and replace the idx or 'name' with your device name or idx
    	local zonTotaal = domoticz.devices(556)
        
    	-- calculate total kWh
    	local kwhOpbrengst = tonumber(domoticz.utils.round((vandaagKwhzon + vandaagKwhzon2),2))   
      
    	-- update total custom sensor
    	zonTotaal.updateCustomSensor(kwhOpbrengst)
    end
} 

Method 2 create a third (dummy) inverter

Create a device with the subtype of kWh. The difference from the first method is that this device acts like a generic inverter. Because it’s an electricity device (not just a counter). This means you can get the values (Watt and kWh) from the other two inverters, add them in a script and use the updateElectricity method to update this dummy ‘inverter’ with the total Watt and kWh values.

Note: do not use WhToday, this is where I spent too much time! Use WhActual and WhTotal. Also see here.

You can see the difference between the first method and second method in the image below: one (555) acts like an actual inverter and the Data is the sum total of both inverters. The other (556) is just a counter.

Here is the DzVents script:

return {
    on = {
        timer = { 'every 5 minutes' }
    },
    execute = function(domoticz, item)
        
        local SE = domoticz.devices(509)
        local GW = domoticz.devices(514)
        local SEGW = domoticz.devices(555)

        -- Calculate combined values
        local combinedWhActual = (SE.WhActual or 0) + (GW.WhActual or 0)
        local combinedWhToday = (SE.WhToday or 0) + (GW.WhToday or 0)
        local combinedWhTotal = (SE.WhTotal or 0) + (GW.WhTotal or 0)

        -- Print combined values
        print("Combined WhActual:", combinedWhActual)
        print("Combined WhToday:", combinedWhToday)
        print("Combined WhTotal:", combinedWhTotal)

        -- Update SEGW device with combined values
        SEGW.updateElectricity(combinedWhActual, combinedWhTotal)
    end
}

Method 3 sum of P1 delivery

When you use a P1 interface you can also get the values from your delivery phases, that your P1 spits out to Domoticz. If you only have one phase, it’s literally the same graph as L1.

If you have 3 phases (which you probably have when you have more than one inverter) you can of course add these phases together.

I haven’t used this myself, but it shouldn’t be too difficult to add these values together with the use of the above scripts. It seems the value would be a little bit more precise.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *