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
Subtracting water counters
Moderators: leecollings, remb0
-
- Posts: 10
- Joined: Tuesday 30 January 2018 22:07
- Target OS: NAS (Synology & others)
- Domoticz version: 2021.1
- Location: France
- Contact:
Subtracting water counters
Synology 1010+ & DS216+ & DS720+ / PI 3 & Domoticz 2021.1 / RFPlayer / ZStick gen5 / Tasmota / Espeasy
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Subtracting water counters
Could look like belowJimmy06 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!
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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: Google [Bot] and 1 guest