Page 1 of 1

Add up current power production from more than one solarpanel system

Posted: Wednesday 14 July 2021 17:18
by banne
If you want to see a total sum of more solar panel systems to monitor the current total production in watt... here is a code for that

Code: Select all

return {

	on = {
	    timer = { 'every 1 minutes' }
	},
	
	execute = function(domoticz, item)
	    
	    local bhPower = domoticz.devices(30)      -- replace the numbers with the idx numbers from your devices or put -- in front of it to disable
	    local fhPower = domoticz.devices(8)    
	    local ahPower = domoticz.devices(21)
	    local chPower = domoticz.devices(18)
	    local dhPower = domoticz.devices(24)
	    local ghPower = domoticz.devices(38)
	    
	    local totalPower = domoticz.devices(56)  --create a customsensor with "watt" as variable and replace 56 with that devices idx
	    
	   local totalPowerupdate = tonumber(domoticz.utils.round((bhPower.WhActual + fhPower.WhActual + ahPower.WhActual + chPower.WhActual + dhPower.WhActual + ghPower.WhActual),2))
	    
	   totalPower.updateCustomSensor(totalPowerupdate)
	   
	end
	
}

Re: Add up current power production from more than one solarpanel system

Posted: Saturday 28 August 2021 22:06
by PieterS
I used the above example to read the actual production of my 3 solarsystems. So I want to know the sum of the actual values

I made a dzVents-script and changed in Settings the status of LoggingLevel to Debug everything.
In the log of Domiticz I get this error:
2021-08-28 21:37:00.382 Error: dzVents: Error: (3.0.11) An error occurred when calling event handler Sum opbrengst
2021-08-28 21:37:00.382 Error: dzVents: Error: (3.0.11) .../var/scripts/dzVents/generated_scripts/Sum opbrengst.lua:15: attempt to perform arithmetic on a nil value (field 'actualWatt')
In the Wiki is told to change to actualWatt but I got the same error with WhActual.
https://www.domoticz.com/wiki/DzVents:_ ... tric_usage

Code: Select all

return {

	on = {
	    timer = { 'every 1 minutes' }
	},
	
	execute = function(domoticz, item)
	    
	    local OmnikPower = domoticz.devices(30)      -- replace the numbers with the idx numbers from your devices or put -- in front of it to disable
	    local SMAPower = domoticz.devices(1249)    
	    local GrowattPower = domoticz.devices(1268)

	    local totalPower = domoticz.devices(1277)  --create a customsensor with "watt" as variable and replace 56 with that devices idx
	    
	    local totalPowerupdate = tonumber(domoticz.utils.round((OmnikPower.actualWatt + SMAPower.actualWatt + GrowattPower.actualWatt),2))
	    
	    totalPower.updateCustomSensor(totalPowerupdate)
	   
	end
}
This are the devices:

Image
Image
Image
Image

Any help is appreciated to get the script working!

Kind regards