Page 1 of 1

lastUpdate object

Posted: Thursday 26 December 2019 16:52
by TimTimTim
Hi everyone,

I am struggling with the lastUpdate object of dzVents. I often use it in combination with the minutesAgo() function in my scripts, but now I want to use the time itself, rather than the comparison to the current time, which I want to show in the log (I want to show the time that my door sensor was triggered in the log, but the script itself is not triggered by the door sensor so I can't use the current time of the system as a proxy).

When I want to ouput dz.device("door").lastUpdate to the log, it gives me an error. Can anyone help me with the correct method to show the time a device was last triggered in the log?

Many thanks and happy holidays

Re: lastUpdate object  [Solved]

Posted: Thursday 26 December 2019 19:15
by waaren
TimTimTim wrote: Thursday 26 December 2019 16:52 I am struggling with the lastUpdate object of dzVents.
lastUpdate is a domoticz / dzVents timeobject.

Hope below script will help you understand the the difference between a time and a time object.

Code: Select all

return {
    on = {
        devices = {
            'lastUpdateTrigger' -- change to a name used on your system or any other trigger 
        }
    },
    execute = function(dz)
        door = dz.devices('door')
        
        lastUpdated = door.lastUpdate -- This is a dz.time object
        
        dz.log ('all attributes of the lastUpdated time object below --------------------' )
        dz.utils.dumpTable(lastUpdated)
        
        dz.log('Last update date / time of ' .. door.name .. ' was ' .. lastUpdated.rawDate .. ' at ' .. lastUpdated.rawTime , dz.LOG_INFO)
    end
}

Re: lastUpdate object

Posted: Wednesday 01 January 2020 22:09
by TimTimTim
Hi,

Thanks for your answer, definately helps! Finally made it work :)