lastUpdate object  [Solved]

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

Moderator: leecollings

Post Reply
TimTimTim
Posts: 2
Joined: Thursday 26 December 2019 16:44
Target OS: -
Domoticz version:
Contact:

lastUpdate object

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

Re: lastUpdate object  [Solved]

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
TimTimTim
Posts: 2
Joined: Thursday 26 December 2019 16:44
Target OS: -
Domoticz version:
Contact:

Re: lastUpdate object

Post by TimTimTim »

Hi,

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

Who is online

Users browsing this forum: No registered users and 1 guest