Page 1 of 1
What type and subtype to use for Water
Posted: Wednesday 02 August 2017 22:06
by jorgh
Hi all,
I'm developing a plugin for measuring my water usage. Using a simple reed relay (costs less than 1 euro

) inserted into my Elster V100 and connecting it to the RPi GPIO.
I've got it working in the sense that I can detect the pulses and calculate waterflow and usage.
For now, I've been using the Gas and Waterflow device types. As Gas seemed the only one reporting cubic meters, and the flow seems just right.
However, for the usage I only see the value I put in the sValue, if I look at my P1 Electricity meter, next to the current counter value, I also see current usage and usage today.
Now my question is, do I need to put in some fancy sValues to also get these kind of reportings in the Gas device type, or is there some other device type that is better suited for this purpose?
Regards,
Jorg
Re: What type and subtype to use for Water
Posted: Monday 07 August 2017 20:57
by uNGam3R
Hello,
Select an incremental counter and then modify it to select "Water".
It will give you a water counter in m3.
You can set up the divide factor in domoticz / configuration. (as default it is set to 100, meaning that when you add 1 it increases of 0.01=10 liters).
The standard use of incremental counter is to set the sValue to the data you want to add to the current counter value.
Hope it helps,
Regards.
Re: What type and subtype to use for Water
Posted: Tuesday 08 August 2017 16:22
by jorgh
@uNGam3R,
Thanks for the tip.
uNGam3R wrote:Hello,
Select an incremental counter and then modify it to select "Water".
It will give you a water counter in m3.
You can set up the divide factor in domoticz / configuration. (as default it is set to 100, meaning that when you add 1 it increases of 0.01=10 liters).
The standard use of incremental counter is to set the sValue to the data you want to add to the current counter value.
Ok, I've created the counter using
Code: Select all
Domoticz.Device(Name='Usage', Unit=WATERUSAGE, TypeName="Counter Incremental").Create()
And manualy changing the type to water. If anyone know how I could also automate that part, please let me know.
Regards,
Jorg
Re: What type and subtype to use for Water
Posted: Tuesday 08 August 2017 16:35
by Milifax
Maybe this helps.
It is my pyhton-script for my watermeter which act on a pulse signal of an arduino.
Basicly the same as your reed-switch, however the script doens't have bounce-protection as this is handled in my arduino nano.
But it updates a watercounter in Domoticz by sending the right JSON and acting on an interrupt on the GPIO.
It is mainly the same script as I found on the forum with some adjustments. Credits to the original poster.
Code: Select all
import RPi.GPIO as GPIO
import time
import urllib2
import os
#Domoticz URL
domoticz_url = "http://127.0.0.1:8080"
#Domoticz IDX of the watersensor
idx = 31
#Reset TimerKeepAlive
TimerKeepAlive = 0
#Board is pin nr, BMC is GPIO nr
#Read output from water meter op pin 40
GPIO.setmode(GPIO.BOARD)
# Set GPIO 21 (Pin 40) als Input aditional as Pullup activated
GPIO.setup(40, GPIO.IN, pull_up_down = GPIO.PUD_UP)
#Functie callback
#Funtion used by interruptcall
def Interrupt(channel):
#Send counter to domoticz JSON
global Counter
Counter = 1
url1 = domoticz_url+'/json.htm?type=command¶m=udevice&idx='+str(idx)+'&svalue='+str(Counter)
req1 = urllib2.Request(url1)
response1 = urllib2.urlopen(req1)
#For debug => print example of JSON-call
#print "JSON call = "+ str(url1)
#print "Watermeter Counter = " + str(Counter)
#Interrupt-Event, NPN off a sensor is 1 and detection is 0
#Detection is 0,falling interupt
GPIO.add_event_detect(40, GPIO.FALLING, callback = Interrupt, bouncetime = 350)
try:
while True:
#Send every 50 minutes [300sec] an update to keep sensor alive in Domoticz
TimerKeepAlive = TimerKeepAlive + 1
#print "Counting time " + str(TimerKeepAlive)
if TimerKeepAlive > 3000:
url1 = domoticz_url+'/json.htm?type=command¶m=udevice&idx='+str(idx)+'&svalue=0'
req1 = urllib2.Request(url1)
response1 = urllib2.urlopen(req1)
#For debug => print JSON-call
#print "JSON call = "+ str(url1)
TimerKeepAlive = 0
else:
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
print "\nBye"