Page 1 of 1

[closed] programmaticly update counter incremental

Posted: Monday 27 February 2023 17:06
by BartSr
Hi!
I use several incremental counters which are updated by MQTT from a NodeMCU.
NodeMCU is connected to counting device ( S0 output, induction sensor)
Sometimes there are missed pulses or to much pulses count due to interference I suppose.
I can synchronise the device by it's "offset" option. This requires some calculation.
I came to the idea to do this without calculation.
Idea: Give userVar the required new value and let DzVent do the calculations and updates.
So far so good.
I read the DzVents wiki and came across the function: device.incrementCounter(value).
According the Wiki this requires some calculation

local newValue = value
local iCounter = domoticz.devices('device name')
local counterDivider = x -- x is depending on the counter divider set for the device
iCounter.incrementCounter( ( -1 * iCounter.counter * counterDivider ) + newValue )

But... The increment value updates both total counter as well as the daily counter.
Now I'm looking for a way to only update the total counter. Is that doable?

Up to now I did not succeed.....

Any sugestions?
TIA
-Bart

Re: programmaticly update counter incremental

Posted: Monday 27 February 2023 22:13
by BartSr
OK, found the answer in a post of Waaren years ago (can't find back that fast).
Waaren wrote that the daily value is composed by ValueNow - Value @ 00.00h