Page 1 of 1

Subtracting water counters

Posted: Thursday 06 August 2020 23:48
by Jimmy06
Hi,

I have 2 water counters, one for the general and one for the house. In between, there is a connection for watering the garden.
In Domoticz, I get the waterflow and an incremental counter for the consumption, for both of them.

I would like to subtract the house from the general to get the waterflow and consumption for the garden... but I am stuck!

If someone could help...

Thanks,

Jimmy

Re: Subtracting water counters

Posted: Friday 07 August 2020 1:02
by waaren
Jimmy06 wrote: Thursday 06 August 2020 23:48 I have 2 water counters, one for the general and one for the house. In between, there is a connection for watering the garden.
In Domoticz, I get the waterflow and an incremental counter for the consumption, for both of them.
I would like to subtract the house from the general to get the waterflow and consumption for the garden... but I am stuck!
Could look like below

When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."

Code: Select all

return 
{
	on = 
	{
		devices = 
		{
		    'totalWaterCounter', -- change to name of your device
		},
	},
	
	logging =
	{
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all ok 
        marker = 'water delta' ,
    },

	execute = function(dz, item)
	    -- change names of your devices between quotes
	    
	    local gardenCounter = dz.devices('gardenCounter')   -- define as type counter
		local gardenFlow = dz.devices('gardenFlow')
		
		local houseCounter = dz.devices('houseCounter').counter   
		local houseFlow = dz.devices('houseFlow')
		local totalFlow = dz.devices('totalFlow')
		
		-- No changes required below this line
	    
		local deltaCounter = item.counter - houseCounter
		local deltaFlow = totalFlow.flow - houseFlow.flow
		
		
		gardenCounter.updateCounter(deltaCounter)
		gardenFlow.updateWaterflow(deltaFlow)

	end
}