Virtual meter that is the sum of two other meters

Moderator: leecollings

ESFnl
Posts: 41
Joined: Saturday 26 December 2015 16:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: The Netherlands
Contact:

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

Post 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
	
}
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

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

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
ESFnl
Posts: 41
Joined: Saturday 26 December 2015 16:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: The Netherlands
Contact:

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

Post 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 ;-)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests