Page 1 of 1

counter incremental updateCounter 'problem'

Posted: Friday 25 August 2017 14:05
by heggink
I have a counter that counts water usage (type counter incremental) called Watermeter2. Whenever a GPIO pin changes, I want to add 1 ltr to the counter. Domoticz measures in 1000's of litres. I tried domoticz.devices('Watermeter2').updateCounter(2) and (2/1000) but the Watermeter total doesn't update even though dzvents says it did:

2017-08-25 14:01:47.864 dzVents: Debug: Dumping domoticz data to /home/pi/domoticz/scripts/dzVents//domoticzData.lua
2017-08-25 14:01:47.878 dzVents: Debug: Event trigger type: device
2017-08-25 14:01:47.895 dzVents: Debug: Found module in /home/pi/domoticz/scripts/dzVents/scripts folder: water
2017-08-25 14:01:47.941 dzVents: Debug: Device-adapter found for GPIO 22: Switch device adapter
2017-08-25 14:01:47.952 dzVents: Debug: Processing device-adapter for GPIO 22: Switch device adapter
2017-08-25 14:01:47.953 dzVents: Debug: Device-event for: GPIO 22 value: Closed
2017-08-25 14:01:47.953 dzVents: Debug: Searching for scripts for changed item: GPIO 22
2017-08-25 14:01:47.953 dzVents: Info: Handling events for: "GPIO 22", value: "Closed"
2017-08-25 14:01:47.953 dzVents: Info: ------ Start external script: water.lua: Device: "GPIO 22 (GPIO)", Index: 14
2017-08-25 14:01:47.953 dzVents: GPIO Triggered Closed
2017-08-25 14:01:47.953 dzVents: Increase watermeter count by 1 LTR Closed
2017-08-25 14:01:47.954 dzVents: Debug: Device-adapter found for Watermeter2: Counter device adapter
2017-08-25 14:01:47.955 dzVents: Debug: Processing device-adapter for Watermeter2: Counter device adapter
2017-08-25 14:01:47.955 dzVents: Info: ------ Finished water.lua
2017-08-25 14:01:47.955 dzVents: Debug: [1] = UpdateDevice: 15|0|0.002

Any ideas?

H

Re: counter incremental updateCounter 'problem'

Posted: Friday 25 August 2017 14:22
by dannybloe
Yeah, I noticed that too when testing. I suspect the counters aren't updated instantly somehow. Have you tried it with the json api?

Re: counter incremental updateCounter 'problem'

Posted: Friday 25 August 2017 16:23
by heggink
Yes and that too works really weird. I reinstated my ESP which works fine: both daily and total counters are updated, i tried JSON and then the total gets updated but the daily only on/off which looks similar to updateCounter().
I looked at the espeasy firmware to see how it calls domoticz (http interface which stills work correct) but could not figure it out just yet. Downside of the ESP approach is that it randomly generates hundreds of litres of water at weird intervals. Swapped tcrt5000, swapped esp module, soldered leads directly, used different gpio ports to no avail. Hence connecting the tcrt straight to the pi's gpio and now I have this other issue.

Never a dull moment :-) if it wasn't for being the laughing stock with 3 women around the house...

Re: counter incremental updateCounter 'problem'

Posted: Friday 25 August 2017 17:45
by randytsuch
Which version of ESP easy are you using?
I've had better success with the mega beta versions over the R120 release.

Re: counter incremental updateCounter 'problem'

Posted: Friday 25 August 2017 17:56
by heggink
Both unfortunately.

Re: counter incremental updateCounter 'problem'

Posted: Friday 25 August 2017 18:01
by heggink
Meanwhile I found that updating with an external python script (on the forum) needs a counter divider of 3000 (triggers on gpio fall where every fall is 1 ltr). Python gpio and domoticz CAN both read the gpio port, right? I do see the gpio updates fine in domoticz but it's as if through dzvents, i need a divider of 1000.

Re: counter incremental updateCounter 'problem'

Posted: Thursday 28 June 2018 21:29
by olleman
Did you ever find a solution for this? This is driving me insane. I'm trying to build a script to put charged current from a solar panel array into one meter and consumption from the batteries into another one. But using dZvent and updateCounter() fails and I never get the sum for the the day, just the instant one. Sending the signal directly from ESPEasy works and Json doesn't work. Whats going on!?

Re: counter incremental updateCounter 'problem'

Posted: Thursday 28 June 2018 21:52
by pwhooftman
olleman wrote: Thursday 28 June 2018 21:29 Did you ever find a solution for this? This is driving me insane. I'm trying to build a script to put charged current from a solar panel array into one meter and consumption from the batteries into another one. But using dZvent and updateCounter() fails and I never get the sum for the the day, just the instant one. Sending the signal directly from ESPEasy works and Json doesn't work. Whats going on!?
You should not use a counter device, but a Electric (Actual + counter) (in Dutch: Elektra (Aktueel + teller). That way, Domoticz adds up all fed actual values to a sum of the day.

Re: counter incremental updateCounter 'problem'

Posted: Friday 29 June 2018 14:19
by olleman
But en incremental counter set to energy should do the same, right? I have real instabillity issues right now and have had to revert to an older database several times. I'm wondering if feeding domoticz counter OR Actual+counter a value like 0.0045786 gives it headache? To many decimals perhaps?

EDIT: Seems like ESPEasy is updatering the energy meter incorrectly and that's what's crashing the database. IT works with json.

Edit2: How does the Electric + counter actually calculate the used power? If I send data from domoticz every 10 seconds and I want the energy i KwH then the value would need to be divided by 60*6=360. So if domoticz is reporting 1000watts usage "right now" then it would set 1000/360 as the "counted value" since a new value will come in the next 10 seconds?

Somethings off because this is my data table to the last couple of hours. The aggregated consumption is always a little low.

Code: Select all

2018-06-30 02:05:00		2570
2018-06-30 02:10:00		2570
2018-06-30 02:15:00		2540
2018-06-30 02:20:00		2560
2018-06-30 02:25:00		2510
2018-06-30 02:30:00		2490
2018-06-30 02:35:00		2450
2018-06-30 02:40:00		2430
2018-06-30 02:45:00		2400
2018-06-30 02:50:00		2390
2018-06-30 02:55:00		2350
2018-06-30 03:00:00	1970	2320
2018-06-30 03:05:00		2290
2018-06-30 03:10:00		2270
2018-06-30 03:15:00		2210
2018-06-30 03:20:00		2230
2018-06-30 03:25:00		2150
2018-06-30 03:30:00		2140
2018-06-30 03:35:00		2110
2018-06-30 03:40:00		2080
2018-06-30 03:45:00		2050
2018-06-30 03:50:00		2010
2018-06-30 03:55:00		1970
2018-06-30 04:00:00	1634	1950
2018-06-30 04:05:00		1890
2018-06-30 04:10:00		1880
2018-06-30 04:15:00		1840
2018-06-30 04:20:00		1820
2018-06-30 04:25:00		1790
2018-06-30 04:30:00		1770
2018-06-30 04:35:00		1770
2018-06-30 04:40:00		1710
2018-06-30 04:45:00		1680
2018-06-30 04:50:00		1670
2018-06-30 04:55:00		1640
2018-06-30 05:00:00	1385	1610
Sorry, this explanation sucks but with my english this is the best I can do :)

Re: counter incremental updateCounter 'problem'

Posted: Thursday 20 June 2019 21:56
by kimot
I found, that for all counters ( incremental too ), function :

domoticz.devices('Counter').updateCounter(value)

do not add ( increment ) value, but set counter state to value.

To increment counter by DZvents you must write something like this:
( add value in pom_spotreba in liters to water counter )

local aktual = domoticz.devices('Counter_spotreba').counter * 1000 + pom_spotreba
domoticz.devices('Counter_spotreba').updateCounter(aktual)

Re: counter incremental updateCounter 'problem'

Posted: Thursday 20 June 2019 22:00
by waaren
kimot wrote: Thursday 20 June 2019 21:56 I found, that for all counters ( incremental too ), function :
domoticz.devices('Counter').updateCounter(value)
do not add ( increment ) value, but set counter state to value.
That is why in dzvents version 2.4.23 the method incrementCounter was implemented for incremental counters

Re: counter incremental updateCounter 'problem'  [Solved]

Posted: Friday 21 June 2019 15:51
by kimot
Oh, very nice.
And thumb up that this information is already in the wiki now.