I have a dzvents program running every 5 minutes. It's been fine as far as i can tell for months now. It calculates the differential value from the main water meter to determine actual water consumed per period (5 minutes).
But, this morning at 6am i ran my irrigation system which consumes around 800 gallons over the course of an hour. In looking at the chart for the virtual point i don't see that spike. Here's what i can see in the main log file of Domoticz:
2026-09-05 07:15:01.018 Status: Set UserVariable LastValue = 101287
2026-09-05 07:20:00.393 Status: Set UserVariable LastValue = 101376
2026-09-05 07:20:01.388 Status: Schedule item started! Name: Sprinkler Zone 3, Type: On Time, DevID: 160, Time: 2026-09-05 07:20:01
2026-09-05 07:25:00.540 Status: Set UserVariable LastValue = 101376
2026-09-05 07:30:00.762 Status: EventSystem: Script event triggered: dzVents/Water usage
2026-09-05 07:30:00.788 Status: Set UserVariable LastValue = 101376
2026-09-05 07:35:01.029 Status: EventSystem: Script event triggered: dzVents/Water usage
2026-09-05 07:35:01.070 Status: Set UserVariable LastValue = 101376
2026-09-05 07:40:00.318 Status: Set UserVariable LastValue = 101376
2026-09-05 07:45:00.715 Status: Set UserVariable LastValue = 101376
I was barely able to catch this as the log file was filling up and dumping the old reports. But, you can see that the Dzvents program saw the difference in the main meter values and stored that delta in my user variable LastValue at 7:20 this morning. That's 890 gallons as the water meter only reports in 10 gallon increments.
In the history file of the virtual point didn't store the differential. Here's a snippet of that file:
2026-09-05 06:00:00 0
2026-09-05 06:05:00 10
2026-09-05 06:10:00 0
2026-09-05 06:15:00 0
2026-09-05 06:20:00 0
2026-09-05 06:25:00 0
2026-09-05 06:30:00 0
2026-09-05 06:35:00 0
2026-09-05 06:40:00 0
2026-09-05 06:45:00 0
2026-09-05 06:50:00 0
2026-09-05 06:55:00 0
2026-09-05 07:00:00 0
2026-09-05 07:05:00 0
2026-09-05 07:10:00 0
2026-09-05 07:15:00 0
2026-09-05 07:20:00 0
2026-09-05 07:25:00 0
2026-09-05 07:30:00 0
2026-09-05 07:35:00 0
2026-09-05 07:40:00 0
And, finally here's the dzvents code that's been working fine as far as i can tell for months.
Code: Select all
return {
on = {
timer = {
'every 5 minutes' -- This is your time trigger
}
},
execute = function(domoticz, timer)
-- 1. Get the current reading
local currentFlow = domoticz.devices('Total water used').sensorValue
-- 2. Retrieve the last saved reading
local lastFlow = domoticz.variables('LastValue').value
-- 3. Calculate the difference
local difference = (currentFlow - lastFlow) * 10
-- 4. Log the results to the Domoticz log
domoticz.log('Current Flow: ' .. currentFlow .. ' Gal', domoticz.LOG_INFO)
domoticz.log('Previous Flow: ' .. lastFlow .. ' Gal', domoticz.LOG_INFO)
domoticz.log('Calculated Difference: ' .. difference .. ' Gal', domoticz.LOG_INFO)
-- 5. OPTIONAL: Update a dummy device with the difference
domoticz.devices('Water usage').updateCustomSensor(difference)
-- 6. Update the persistent variable for the next run
domoticz.variables('LastValue').set(currentFlow)
end
}No errors in the log file.
Any help on this would be greatly appreciated.
Thank you,
Darryl