.compare and dz.data issue [solved]
Posted: Wednesday 27 January 2021 8:58
Hello,
I use .compare to compare 2 times T1 and T2
In one direction it's ok: T1.compare(T2)
In the other it's KO: T2.compare(T1)
when I save T2 in dz.data
If T2 = dz.time directly (or first run of the script), it's ok in both directions
Version: 2020.2 (build 12819)
Compile Date: 2021-01-04 08:00:57
dzVents Version: 3.1.0
I should miss something, but what?
I use .compare to compare 2 times T1 and T2
In one direction it's ok: T1.compare(T2)
In the other it's KO: T2.compare(T1)
when I save T2 in dz.data
If T2 = dz.time directly (or first run of the script), it's ok in both directions
Code: Select all
local DEVICES = {203}
return {
logging = {
level =
domoticz.LOG_DEBUG,
},
on = {
devices = DEVICES,
},
data = {
DEOLtime = {},
},
execute = function(dz, the_device, triggerInfo)
local LOG_LEVEL = dz.LOG_DEBUG
local l_DEOLtime
l_DEOLtime = dz.data.DEOLtime
if l_DEOLtime == nil then
l_DEOLtime = dz.time
print ('l_DEOLtime == nil')
else
print ('l_DEOLtime not nil')
end
print ('l_DEOLtime= ' .. l_DEOLtime.raw)
l_DEOLtimeTmp = dz.time.addSeconds(120)
print ('l_DEOLtimeTmp ' .. l_DEOLtimeTmp.raw)
local l_DEOLComp
l_DEOLComp = l_DEOLtimeTmp.compare(l_DEOLtime).compare
print ('l_DEOLComp ' .. l_DEOLComp)
l_DEOLComp = l_DEOLtime.compare(l_DEOLtimeTmp).compare
print ('l_DEOLComp ' .. l_DEOLComp)
dz.data.DEOLtime = l_DEOLtime
end}
Code: Select all
021-01-27 08:47:54.916 Status: dzVents: Info: ------ Start internal script: zTimeCompareData2: Device: "test inter 203 (Dummy)", Index: 203
2021-01-27 08:47:54.917 Status: dzVents: l_DEOLtime == nil
2021-01-27 08:47:54.917 Status: dzVents: l_DEOLtime= 2021-1-27 8:47:54.743
2021-01-27 08:47:54.918 Status: dzVents: l_DEOLtimeTmp 2021-01-27 08:49:54
2021-01-27 08:47:54.918 Status: dzVents: l_DEOLComp -1
2021-01-27 08:47:54.918 Status: dzVents: l_DEOLComp 1
2021-01-27 08:47:54.921 Status: dzVents: Info: ------ Finished zTimeCompareData2
2021-01-27 08:48:00.851 Status: EventSystem: Script event triggered: /home/pi/PROD_domoticz/dzVents/runtime/dzVents.lua
2021-01-27 08:48:07.891 Status: dzVents: Info: ------ Start internal script: zTimeCompareData2: Device: "test inter 203 (Dummy)", Index: 203
2021-01-27 08:48:07.892 Status: dzVents: l_DEOLtime not nil
2021-01-27 08:48:07.892 Status: dzVents: l_DEOLtime= 2021-1-27 8:47:54.743
2021-01-27 08:48:07.893 Status: dzVents: l_DEOLtimeTmp 2021-01-27 08:50:07
2021-01-27 08:48:07.893 Status: dzVents: l_DEOLComp -1
2021-01-27 08:48:07.893 Status: dzVents: Info: ------ Finished zTimeCompareData2
2021-01-27 08:48:07.893 Error: dzVents: Error: (3.1.0) An error occurred when calling event handler zTimeCompareData2
2021-01-27 08:48:07.893 Error: dzVents: Error: (3.1.0) .../scripts/dzVents/generated_scripts/zTimeCompareData2.lua:37: attempt to call a nil value (field 'compare')Compile Date: 2021-01-04 08:00:57
dzVents Version: 3.1.0
I should miss something, but what?