Page 1 of 1

.lastupdate

Posted: Tuesday 08 January 2019 9:48
by poudenes
Hi All,

Is there any way to get a lastupdate within seconds?
I want try to create a script that looks to follow:

Switch test goes active
if lastupdate is < 1 sec then action 1
else action 2

When i use switch and press 1 time i want turn lights on normal
When i press it again within 1 second then turn lights on with a different color

Re: .lastupdate

Posted: Tuesday 08 January 2019 10:29
by poudenes
idea is not working at all... grrrr

Re: .lastupdate

Posted: Tuesday 08 January 2019 10:34
by waaren
poudenes wrote: Tuesday 08 January 2019 9:48 Is there any way to get a lastupdate within seconds?
Yes, But are you that quick ? :D

Code: Select all

return {

   on = { devices = { "Your device name" }},

   logging = { level    = domoticz.LOG_DEBUG,
               marker   = "Long time ago there was ... "}, 
               
   execute = function(dz, item )
   
        local function logWrite(str,level)
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        if item.state == "On" then
            logWrite(item.name .. " was previously updated " .. item.lastUpdate.millisecondsAgo .. " milliseconds ago")
        end
   end
}