Reset incremental counter does not work
Posted: Thursday 07 January 2021 10:04
I have created a water meter in Domoticz using an inductieve NPN sensor on a GPIO of my Pi. The puls from the NPN increments an incremental counter and for that I use dzVents. Everything works fine and the counter is in sync with the real water meter.
Now I want to monitor the water usage of one day. So I created a second incremental counter. This counter I want to reset to zero at 0:00 h. Only problem is that it does not reset to zero.
For what I understand from the dzVents documentation the updateCounter statement should overwrite the value of the counter. But nothing seems to happen. So as an experiment I changed the updateCounter(0) with updateCounter(1) and to my surprise the counter got incremented.
What I want is the 0.285 value in the image above to reset to zero at midnight. I want to use this value in Dashticz to present today's water usage.
Can anybody help?
Now I want to monitor the water usage of one day. So I created a second incremental counter. This counter I want to reset to zero at 0:00 h. Only problem is that it does not reset to zero.
Code: Select all
return {
on = { timer = {'at 0:00'},
devices = { 'Waterpuls' },
},
execute = function(domoticz, device)
if (device.trigger == 'at 0:00') then
domoticz.devices('Waterverbruik dag').updateCounter(0)
print ('Reset Waterverbruik dag')
end
if (device.name == 'Waterpuls' and device.state == 'On') then
domoticz.devices('Waterverbruik').incrementCounter(1)
domoticz.devices('Waterverbruik dag').incrementCounter(1)
end
end
}
Can anybody help?