Page 1 of 1
closed] getting value of watercounter
Posted: Wednesday 18 May 2022 23:25
by BartSr
Hi,
I am having an working incremental counter which monitors the water consumption
Daily consumption is shown as 0,191m3 whereas total shows 939.995m3.
So far so good.
Now I like to see these values in a lua script.
I am not good using lua so I will do step by step (goal is to create daily file with time interval of e.g.10 minutes)
In lua I coded:
print(otherdevices_svalues['watermeter'])
Now I get this in logfile:
2022-05-18 23:22:04.412 Status: LUA: 18446744073709379679
What does this show while looking at 0,191m3 and 939.995 m3?
TIA for your help
-Bart
Re: getting value of watercounter
Posted: Thursday 19 May 2022 11:40
by waltervl
If you are not good at LUA better learn DzVents as there it is just very easy to get it.
In LUA it seems not possible (please someone correct me if wrong). See also
viewtopic.php?p=282202
Re: getting value of watercounter
Posted: Thursday 19 May 2022 11:41
by Toulon7559
Please publish the complete lua-script, enabling the forum to see whether the declaration of values is correct.
Publishing is easiest if you set the code-markers and then copy the script-text inbetween those 2 markers, as shown below.
If the script is long, use
spoiler to set the markers: then the view is small, but contents can easily be called.
Re: getting value of watercounter
Posted: Thursday 19 May 2022 20:55
by BartSr
Here we go; as said I am going step by step. So 1st step is : how to get the value of a device
Code: Select all
commandArray = {}
local a
print ("watermeter")
print(otherdevices_svalues['watermeter'])
a = otherdevices_svalues['watermeter']
print (a)
return commandArray
if I want to see a tempvalue I do:
(I find expected tempvalue in logfile)
Code: Select all
commandArray = {}
local a
a = otherdevices_svalues['Vv trapgat aanvoer']
print (a)
return commandArray
So as shown here
viewtopic.php?p=282202
It seems to be impossible to catch a counters'value. This is weird for me.
Any suggestion?
TIA
-Bart
Re: getting value of watercounter
Posted: Thursday 19 May 2022 20:58
by BartSr
@Watervl:
I.ve been programming databases for years using procedural code as well as OOP.
For me LUA is closest to those.
DzVents is very steep learning curve for me.
Re: getting value of watercounter
Posted: Sunday 05 June 2022 17:10
by BartSr
Nobody who has an advise?
KR
-Bart
Re: getting value of watercounter
Posted: Wednesday 15 June 2022 0:46
by RonkA
Hello,
print(otherdevices_svalues['watermeter']) gave you 2022-05-18 23:22:04.412 Status: LUA: 18446744073709379679
Is the status output a constant number or is it changing?
Also in your latter post it states /a = otherdevices_svalues['Vv trapgat aanvoer']/ that looks to me not relevant to the counter..
Grt Ron.
Re: getting value of watercounter
Posted: Monday 20 June 2022 14:44
by BartSr
Hi Ron,
I did not check for some time but currently it sents: 18446744073709369520
So there is a change.
KR
-Bart
Re: getting value of watercounter
Posted: Monday 20 June 2022 15:30
by RonkA
Im NOT a educated person in programming but i like tinkering,
You didn't disclose the type of meter, maybe a manual wil give some clarity?
It could be there are more values beeng delivered like 2 or more.. like P1data gives out 6 values.
I have a script thats getting 2 values out of a solarmeter device, maybe this could get other values out of your meter
Code: Select all
solar_p, solar_e = otherdevices_svalues[solarmeter]:match("([^;]+);([^;]+)")
solar_p is getting the current power and solar _e is the day couter,.
Modify and try i would say..
Re: getting value of watercounter
Posted: Monday 20 June 2022 15:52
by BartSr
Thanks fro your help Ron, but the problem is that what I am measuring is just counting the number of rotations of the watermeter.
That gives correct indication in Domoticz. But when I want to retrieve the value, as shown by Domoticz as a scriptvalue the weird data is received.