How "fresh" is my variable ?  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
jpr105
Posts: 6
Joined: Friday 07 June 2019 10:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How "fresh" is my variable ?

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jpr105
Posts: 6
Joined: Friday 07 June 2019 10:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How "fresh" is my variable ?

Post by jpr105 »

Perfect ! It works :D
Thanks a lot
Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest