counter incremental updateCounter 'problem' [Solved]
Moderator: leecollings
- heggink
- Posts: 979
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
counter incremental updateCounter 'problem'
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
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
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: counter incremental updateCounter 'problem'
Yeah, I noticed that too when testing. I suspect the counters aren't updated instantly somehow. Have you tried it with the json api?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
- heggink
- Posts: 979
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: counter incremental updateCounter 'problem'
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...
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

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 90
- Joined: Sunday 20 March 2016 18:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: LA, Ca USA
- Contact:
Re: counter incremental updateCounter 'problem'
Which version of ESP easy are you using?
I've had better success with the mega beta versions over the R120 release.
I've had better success with the mega beta versions over the R120 release.
- heggink
- Posts: 979
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: counter incremental updateCounter 'problem'
Both unfortunately.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
- heggink
- Posts: 979
- Joined: Tuesday 08 September 2015 21:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 12451
- Location: NL
- Contact:
Re: counter incremental updateCounter 'problem'
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.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
-
- Posts: 107
- Joined: Thursday 01 January 2015 18:56
- Target OS: Linux
- Domoticz version:
- Contact:
Re: counter incremental updateCounter 'problem'
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!?
-
- Posts: 75
- Joined: Monday 11 November 2013 18:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: counter incremental updateCounter 'problem'
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.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!?
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
-
- Posts: 107
- Joined: Thursday 01 January 2015 18:56
- Target OS: Linux
- Domoticz version:
- Contact:
Re: counter incremental updateCounter 'problem'
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.
Sorry, this explanation sucks but with my english this is the best I can do 
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

-
- Posts: 105
- Joined: Saturday 25 November 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Czech Rep.
- Contact:
Re: counter incremental updateCounter 'problem'
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)
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)
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: counter incremental updateCounter 'problem'
That is why in dzvents version 2.4.23 the method incrementCounter was implemented for incremental counters
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 105
- Joined: Saturday 25 November 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Czech Rep.
- Contact:
Re: counter incremental updateCounter 'problem' [Solved]
Oh, very nice.
And thumb up that this information is already in the wiki now.
And thumb up that this information is already in the wiki now.
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
Who is online
Users browsing this forum: No registered users and 1 guest