Page 2 of 2

Re: Virtual meter that is the sum of two other meters

Posted: Saturday 08 October 2022 23:29
by ESFnl
Sorry to reply to an old post. I was searching for a similar script to sum multiple devices to one (virtual one).

I update the script with my idx numbers but receive this error in the log:

Code: Select all

2022-10-08 23:20:17.564 Error: dzVents: Error: (3.0.2) Method updateElectricity is not available for device "kWh Meter Pool Total" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
Do you have any suggestions how to fix this?

This is the script I've changed in the Webeditor

Code: Select all

return {

	on = {
	    timer = { 'every 5 minutes' }
	},
	
	execute = function(domoticz, item)
	    
	    local ppPower = domoticz.devices(641)      -- pool pump power meter
	    local plPower = domoticz.devices(659)     -- pool light power meter
	    local paPower = domoticz.devices(647)      -- pool air pump power meter
	    local puPower = domoticz.devices(653)     -- pool UV power meter
	    local totalPower = domoticz.devices(661)  -- total pool power meter
	    
	    totalPower.updateElectricity(
            	ppPower.WhActual + plPower.WhActual + paPower.WhActual + puPower.WhActual,
            	ppPower.WhTotal + plPower.WhTotal + paPower.WhTotal + puPower.WhTotal
            )
	    
	end
	
}

Re: Virtual meter that is the sum of two other meters

Posted: Monday 17 October 2022 15:00
by waltervl
function .updateElectricity() is only available for device type kWh, Electricity (instant and counter)
If your device 661 "kWh Meter Pool Total" is another type you probably need another update function .updateEnergy()
See for more info the documentation about reading and updating specific device types: https://www.domoticz.com/wiki/DzVents:_ ... ic_devices

Re: Virtual meter that is the sum of two other meters

Posted: Sunday 30 October 2022 22:44
by ESFnl
Thank you very much, waltervl!

Changing updateElectricity() into updateEnergy() works! Now I have 4 devices summed to one.

A stacked chart would be nicer, but I'm not gonna try as a beginner ;-)