Page 1 of 1

How "fresh" is my variable ?

Posted: Friday 07 June 2019 10:55
by jpr105
Hi,

Sorry for my English, so let's try. I'm new in Domoticz but I already have a Fibaro HC2 (LUA and so on) and I would like to create some dzVents scripts.
My problem is very simple : I would like to know when a specific variable has been updated.
I can see this update date doing a JSON request :
http followed by IP:8080/json.htm?type=command&param=getuservariable&idx=12
{
"result" : [
{
"LastUpdate" : "2019-06-07 09:45:39",
"Name" : "CtrZ1On",
"Type" : "0",
"Value" : "1",
"idx" : "12"
}
],
"status" : "OK",
"title" : "GetUserVariable"
}
The last update time is "2019-06-07 09:45:39" in this example

The syntax I use to retrieve the value is : local CtrZ1On = domoticz.variables('CtrZ1On').value which is very simple and intuitive

But I have problems when I try this local CtrZ1OnFreshness = domoticz.variables('CtrZ1On').lastUpdate

May be syntax, may be variable time ... I would't spend hours reading tons of documentation ... so cant everyone help me :roll: ?

Thanks in advance

Regards - Jean-Paul

Re: How "fresh" is my variable ?  [Solved]

Posted: Friday 07 June 2019 16:01
by waaren
jpr105 wrote: Friday 07 June 2019 10:55 I have problems when I try this local CtrZ1OnFreshness = domoticz.variables('CtrZ1On').lastUpdate
If you look at this dzVents wiki topic you will read that the lastUpdate attribute is a time object . A time object in dzVents is in fact a table with values, functions and .. tables.
I assume you need something like a date; so the syntax could be like

Code: Select all

CtrZ1OnFreshness = domoticz.variables('CtrZ1On').lastUpdate.raw

Re: How "fresh" is my variable ?

Posted: Friday 07 June 2019 17:45
by jpr105
Perfect ! It works :D
Thanks a lot
Regards