device.lastupdate in a device script

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

Moderator: leecollings

Post Reply
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

device.lastupdate in a device script

Post by jmleglise »

Hi,

I don't understand the use of lastupdate. I thought that on a device script, for the device which trigger the script, it was supposed to return the last modification date before the execution of the script. (not the one which trigger the script).

Look :

Code: Select all

return 
{
    on = 
    {
        devices =  { 'Door3',  },
    },

    execute = function(dz, item)

    print('system:'..dz.time.rawTime)
    print('Domoticz:'..dz.settings.domoticzVersion)
    print('dzvents:'..dz.settings.dzVentsVersion)
    print( ' --------the trigger---------' )   
    print(item.name .. ' seconds ago' ..item.lastUpdate.raw )
    print(item.name .. ' seconds ago' ..dz.devices('Door3').lastUpdate.raw )
    print( ' --------to compare another one ---------' )
    print(dz.devices('Door2').lastUpdate.raw )   
    end
}

2021-02-03 12:11:26.516 (Z-WAVE) General/Alarm (Alarm Type: Access Control 6 (0x06))
2021-02-03 12:11:26.531 (Z-WAVE) Light/Switch (Access Control)
2021-02-03 12:11:26.547 (Z-WAVE) Light/Switch (Door3)
2021-02-03 12:11:26.512 Status: OpenZWave: Alarm received (Access Control: Door/Window Open), NodeID: 7 (0x07)
2021-02-03 12:11:26.838 Status: dzVents: system:12:11:26
2021-02-03 12:11:26.838 Status: dzVents: Domoticz:2020.2
2021-02-03 12:11:26.838 Status: dzVents: dzvents:3.0.2
2021-02-03 12:11:26.838 Status: dzVents: --------the trigger---------
2021-02-03 12:11:26.839 Status: dzVents: Door3 seconds ago2021-02-03 12:11:26
2021-02-03 12:11:26.839 Status: dzVents: Door3 seconds ago2021-02-03 12:11:26
2021-02-03 12:11:26.839 Status: dzVents: --------to compare another one ---------
2021-02-03 12:11:26.841 Status: dzVents: 2021-02-02 23:19:23


My need is simple : I want to play a sound when the door opens, but only if there has been no movement for 5 minutes.
with somehing like : if (item.state == 'Open' and item.lastUpdate.minutesAgo > 2) then


What do you think ?
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: device.lastupdate in a device script

Post by waaren »

jmleglise wrote: Wednesday 03 February 2021 12:21 What do you think ?
If your version is really V3.5113 (as in your profile) you can hardly expect any useful comment on this question. This version was even before dzVents made it to version 1.0.
Since then many areas of domoticz and dzVents changed and many bugs were fixed among them also some bugs in the area of the lastUpdate processing.

Most recent fix in this area ( github issue 4112) was merged into to V2020.2 build 12002.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: device.lastupdate in a device script

Post by jmleglise »

Hi waaren, thank you very much, This drived me crazy ...

I m in 2020.2.11995

So you advice to me to update with the beta channel ? (now : 2020.2.12913)

There is no strange behavior in this one ? :-)
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: device.lastupdate in a device script

Post by waaren »

jmleglise wrote: Wednesday 03 February 2021 13:49 I m in 2020.2.11995
So you advice to me to update with the beta channel ? (now : 2020.2.12913)
My only advise it to update your profile :) .
if you want to move to the beta channel is up to you.
There is no strange behavior in this one ? :-)
If you mean to ask if this Beta is without bugs?
Yes. It's 100% error free and even world peace is now implemented
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: swen and 1 guest