lastUpdate not the last!
Posted: Sunday 26 June 2022 20:00
I've discovered there https://github.com/domoticz/domoticz/issues/4466
that
2 scripts to test it
the log
But it's the same for the other device dev2 = 460
even though it was updated after
and that it was not the trigger!
You would say that, we could know that it was updated with the one triggered, but we could have different conditions for the update and so the result is that we don't know if it was updated or not
that
But I think it doesn't work like this...When the script is triggered by the device update you already know when it is updated (it is updated now)
The lastupdate value is updated after the script is triggered.
[...]
but my comment is true for scripts triggered by the device update. If you use a time based script or a script triggered by a different device and probe for the lastUpdate time it should report the real lastUpdate time
This is how it should work by design
2 scripts to test it
Code: Select all
-- the trigger script
LOGGING = domoticz.LOG_DEBUG
LOG_LEVEL = domoticz.LOG_DEBUG
local dev0 = 214
local dev1 = 271
local dev2 = 460
return {
logging = { level = LOGGING,
},
on = {
devices = {dev0}
},
execute = function(dz, triggerObject)
_G.logMarker = dz.moduleLabel
dz.devices(dev1).toggleSwitch()
dz.devices(dev2).toggleSwitch()
end
}
Code: Select all
-- the triggered script
LOGGING = domoticz.LOG_DEBUG
LOG_LEVEL = domoticz.LOG_DEBUG
local dev1 = 271
local dev2 = 460
return {
logging = { level = LOGGING,
},
on = {
devices = {dev1}
},
execute = function(dz, triggerObject)
_G.logMarker = dz.moduleLabel
dz.log(dz.devices(dev1).id .. ' ' .. dz.devices(dev1).lastUpdate.raw)
dz.log(dz.devices(dev2).id .. ' ' .. dz.devices(dev2).lastUpdate.raw)
end
}- Spoiler: show
Code: Select all
z_triggered: 271 2022-06-26 19:40:35Code: Select all
z_triggered: 460 2022-06-26 19:40:35Code: Select all
2022-06-26 19:41:59.491 Status: dzVents: Debug: z_trigger: Processing device-adapter for test 460: Switch device adapter
2022-06-26 19:41:59.491 Status: dzVents: Debug: z_trigger: Constructed timed-command: OffYou would say that, we could know that it was updated with the one triggered, but we could have different conditions for the update and so the result is that we don't know if it was updated or not