Add up current power production from more than one solarpanel system

Moderator: leecollings

Post Reply
banne
Posts: 5
Joined: Wednesday 14 July 2021 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Add up current power production from more than one solarpanel system

Post 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
	
}
PieterS
Posts: 196
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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
Synology with Domoticz build (V2024.7) in Docker
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests