Time in minutes or hours
Posted: Wednesday 16 June 2021 22:39
hello! i copied this code from an earlier post and it works fine, but i want it in minutes or hours instead for my heater if possible?
Code: Select all
return
{
on =
{
devices =
{
1324, -- device for which you want to record the On time.
},
},
data =
{
lastOn = { initial = 0 },
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'timeKeeper',
},
execute = function(dz, item)
local secondsActive = 0
local iCounter = dz.devices('timeKeeper') -- define as virtual incremental counter
if item.active then
if dz.data.lastOn == 0 then dz.data.lastOn = os.time() end
return
else
if dz.data.lastOn == 0 then
secondsActive = os.time() - item.lastUpdate.dDate
else
secondsActive = os.time() - dz.data.lastOn
dz.data.lastOn = 0
end
iCounter.updateCounter(secondsActive)
end
end
}