.lastupdate

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

Moderator: leecollings

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

.lastupdate

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: .lastupdate

Post by poudenes »

idea is not working at all... grrrr
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .lastupdate

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest