commandArray = {}
-- Water usage
-- Retrieve value from water meter device:
sWaterUsage = otherdevices_svalues['Watermeter']
-- To have a better readable format, divide number by 1000:
sWaterUsagePrint = tonumber(sWaterUsage / 1000);
-- calculation is done with the unmodified water value
sWaterUsage = tonumber(sWaterUsage);
-- For Debuging
print("Water usage until now is " .. sWaterUsagePrint .. "m3 ")
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
if (devicechanged['GPIO Watermeter'] == 'Off')
then
sWaterUsageTot = (sWaterUsage + 1)
print("Water usage is set to " .. sWaterUsageTot / 1000 .. "m3 ");
commandArray['UpdateDevice'] = '8|0|'..sWaterUsageTot..''
os.execute('wget http://IPADDRESS:PORT/json.htm?type=command¶m=udevice&idx=IDX&svalue='..sWaterUsageTot..' -O /dev/null')
else
-- Keep a live device
if (timedifference(otherdevices_lastupdate["Watermeter"]) > 300)
then
print("Water usage is still " .. sWaterUsage / 1000 .. "m3 ");
commandArray['UpdateDevice'] = '8|0|'..sWaterUsage..''
os.execute('wget http://IPADDRESS:PORT/json.htm?type=command¶m=udevice&idx=IDX&svalue='..sWaterUsage..' -O /dev/null')
end
end
return commandArray
Do you get some sort of error in the log? Looks oke to me. Is the ip included in your system settings network e.g. 127.0.0.*;192.168.*.* of both devices? Executing in browser should be the same as in script. You can use a print for debuging instead of os.execute. Otherwise I need to create a simmilar environment to test it in real.
pvangorp wrote: ↑Friday 13 October 2017 20:58
Do you get some sort of error in the log? Looks oke to me. Is the ip included in your system settings network e.g. 127.0.0.*;192.168.*.* of both devices? Executing in browser should be the same as in script. You can use a print for debuging instead of os.execute.
I can see the lua script being triggerd but the master device is not being updated.
I don't see any errors at all. I'try the print option.
pvangorp wrote: ↑Friday 13 October 2017 20:58
Do you get some sort of error in the log? Looks oke to me. Is the ip included in your system settings network e.g. 127.0.0.*;192.168.*.* of both devices? Executing in browser should be the same as in script. You can use a print for debuging instead of os.execute.
I can see the lua script being triggerd but the master device is not being updated.
I don't see any errors at all. I'try the print option.
thank you!
Strange, it seems nothing happens. is this what you meant with "print"?
commandArray = {}
-- Water usage
-- Retrieve value from water meter device:
sWaterUsage = otherdevices_svalues['Watermeter']
-- To have a better readable format, divide number by 1000:
sWaterUsagePrint = tonumber(sWaterUsage / 1000);
-- calculation is done with the unmodified water value
sWaterUsage = tonumber(sWaterUsage);
-- For Debuging
print("Water usage until now is " .. sWaterUsagePrint .. "m3 ")
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
if (devicechanged['GPIO Watermeter'] == 'Off')
then
sWaterUsageTot = (sWaterUsage + 1)
print("Water usage is set to " .. sWaterUsageTot / 1000 .. "m3 ");
commandArray['UpdateDevice'] = '8|0|'..sWaterUsageTot..''
print('wget http://192.168.1.94:8080/json.htm?type=command¶m=udevice&idx=157&svalue='..sWaterUsageTot..' -O /dev/null')
else
-- Keep a live device
if (timedifference(otherdevices_lastupdate["Watermeter"]) > 300)
then
print("Water usage is still " .. sWaterUsage / 1000 .. "m3 ");
commandArray['UpdateDevice'] = '8|0|'..sWaterUsage..''
print('wget http://192.168.1.94:8080/json.htm?type=command¶m=udevice&idx=157&svalue='..sWaterUsage..' -O /dev/null')
end
end
return commandArray
it doen't show anything at all in the log file. it's just like the line is not being used.
pvangorp wrote: ↑Friday 13 October 2017 21:27
What happens when you swap the commandarray and weet line order. The print above the commandarray is in the log?
pvangorp wrote: ↑Friday 13 October 2017 21:27
What happens when you swap the commandarray and weet line order. The print above the commandarray is in the log?
New feature tip. You can hide the dummy “GPIO Watermeter” by putting a $ in front of the name (don’t forget to change the script aswell) or put the device in the “hidden devices” Floor plan.
Hobbybob wrote: ↑Sunday 13 August 2017 20:36
Okay, I've tried to read up on the information about this, and I came up with the following wiring-scheme. As said, I am not very good at reading diagrams with symbols, so I made something a litte more visual for myself.
Can anybody with a little more knowledge than me check if this would be a good way? I calculated the 1kOhm and 2kOhm on the site oohlaf mentioned, and fiddled with the Ohms to get two values that I can actually buy, and produces as close to 3.3V as possible.
Schakeling watermeter.jpg
Ok I would like to have some more information about this setup..
I am about to connect the same sensor on my Raspberry pi3.
I have read about the voltage being 3,3V but My raspberry has (2) 5 volt connections on the GPIO.
So my real question is.. do I need the resistors shown in the diagram? as I am putting 5 volt in.....
Many thanks for any info.
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch
pvangorp wrote: ↑Friday 13 October 2017 21:27
What happens when you swap the commandarray and weet line order. The print above the commandarray is in the log?
Hobbybob wrote: ↑Sunday 13 August 2017 20:36
Okay, I've tried to read up on the information about this, and I came up with the following wiring-scheme. As said, I am not very good at reading diagrams with symbols, so I made something a litte more visual for myself.
Can anybody with a little more knowledge than me check if this would be a good way? I calculated the 1kOhm and 2kOhm on the site oohlaf mentioned, and fiddled with the Ohms to get two values that I can actually buy, and produces as close to 3.3V as possible.
Schakeling watermeter.jpg
Ok I would like to have some more information about this setup..
I am about to connect the same sensor on my Raspberry pi3.
I have read about the voltage being 3,3V but My raspberry has (2) 5 volt connections on the GPIO.
So my real question is.. do I need the resistors shown in the diagram? as I am putting 5 volt in.....
LouiS22 wrote: ↑Wednesday 11 October 2017 10:35
Is there any way to transfer these values from a slave PI to a Master PI? (Virtual counters don't get updated this way ).
I'm just curious why everybody seems to think that the slave-pi in this situation needs to run Domoticz? I have a slave-pi in my house to read out a quad current meter that I have installed in my meter closet (better English than meter cast ) to give more granularity per breaker-group than my p1 smart-meter does. I just update the counters/meters/switches in my main (and only) Domoticz instance (running on a NUC incidentally, not a pi) using JSON.
is an example of how I update 'remotely' without having to have Domoticz locally on the remote machine. What's the benefit of having Domoticz on the slave-pi - might be easier than DDNS if the master and slave pi's are not on the same WiFi?
Hobbybob wrote: ↑Sunday 13 August 2017 20:36
Okay, I've tried to read up on the information about this, and I came up with the following wiring-scheme. As said, I am not very good at reading diagrams with symbols, so I made something a litte more visual for myself.
Can anybody with a little more knowledge than me check if this would be a good way? I calculated the 1kOhm and 2kOhm on the site oohlaf mentioned, and fiddled with the Ohms to get two values that I can actually buy, and produces as close to 3.3V as possible.
Schakeling watermeter.jpg
Ok I would like to have some more information about this setup..
I am about to connect the same sensor on my Raspberry pi3.
I have read about the voltage being 3,3V but My raspberry has (2) 5 volt connections on the GPIO.
So my real question is.. do I need the resistors shown in the diagram? as I am putting 5 volt in.....
pvangorp wrote: ↑Monday 30 October 2017 11:28
To your input GPIO of your Pi. Check your zener diode with a voltage meter. It does mater how you connect it. If wrong it stil gives 5v to your pi!
Ok I am not an expert in zenerdiodes. So what is the correct way? how do I check it with a voltage meter?
what to look for?
Hardware: Raspberry Pi 3, OTGW, 433MHz Superheterodyne 3310 RF Link
Software: Ubuntu 16.04, Domoticz v3.5468, WiringPi, rc-switch