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.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 ?