(Sorry to revive an old topic, but I couldn't find anything more recent.)
waaren wrote: ↑Friday 14 February 2020 16:47
The compare method require two dzVents time objects.
Code: Select all
return
{
on =
{
timer =
{
'every minute',
},
},
execute = function(dz)
local myTime = '15:00:00'
local someTime = dz.time.makeTime(dz.time.rawDate .. ' ' .. myTime) -- this will create the time object someTime
-- compare require two dzVents time objects (first one here is dz.time, second one is someTime )
dz.log('Delta time between ' .. dz.time.rawTime .. ' and ' .. someTime.rawTime .. ' is ' .. dz.time.compare(someTime).minutes .. ' minutes.', dz.LOG_FORCE)
end
}
After a lot of studying, I still fail to understand how the Compare function should be used.
As far as I understand, this "dz.time.compare(someTime).minutes" only compares the
current time with the time stored in the time object "someTime" and returns that difference in a number of minutes.
But how can one compare two time objects named for instance "Time1" and "Time2"?
The manual doesn't help either, see
https://wiki.domoticz.com/DzVents:_next ... ime_object
Code: Select all
-- compare two times
print(domoticz.time.compare(myDevice.lastUpdate).secs))
It says it compares two times, but all it does is compare the current time with another time....