[closed] programmaticly update counter incremental

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
BartSr
Posts: 491
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.7
Location: Netherlands
Contact:

[closed] programmaticly update counter incremental

Post 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
Last edited by BartSr on Monday 27 February 2023 22:13, edited 1 time in total.
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
BartSr
Posts: 491
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.7
Location: Netherlands
Contact:

Re: programmaticly update counter incremental

Post 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
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest