I seem to keep falling over, trying to return the time of a (the last actually) entry in persistent data.
I wish to use this in a notification, to tell WHEN something as last done. the actual data in this case is meaningless, as it is simply binary.
Code: Select all
return {
on = {
devices = {
'$FridgeOpen',
},
timer = {
'at 09:00', 'at 14:00', 'at 19:00', 'at 20:00', 'at 22:00',
},
},
data = {myHistoryFridge = { history = true, maxItems = 50 , maxHours = 72 },
},
execute = function(domoticz, item)
local lastupdate = domoticz.devices('Fridge').LastUpdate--lastUpdate --Time(node.LastUpdate)
if ((item.isDevice)) then
domoticz.devices('Fridge').open()
domoticz.data.myHistoryFridge.add(1)
end
if (item.isTimer) then
if (domoticz.devices('Fridge').lastUpdate.minutesAgo > 60 ) and (domoticz.devices('Emma At Home').state == 'On' or domoticz.devices('Nigel At Home').state == 'On' ) then --at 12:45-21:15 and domoticz.time.matchesRule('at 07:30-11:00') ) then --at 12:45-21:15
domoticz.log(' Fridge not opened since ' .. tostring(domoticz.datalastUpdate), domoticz.LOG_INFO)
domoticz.notify(' Fridge not opened since ' .. tostring(domoticz.data.lastUpdate) ..' Mins Ago')
end
end
domoticz.log(' Fridge Last opened ' .. tostring(domoticz.data.lastUpdate), domoticz.LOG_INFO)
end
}
However I am trying to output the actual timestamp