28.12.2021, 08:31
@Dré, you need to change the storage key ('ontime'), not the variable name:
If using multiple timers you can combine the scheduled/resident scripts into one.
Code:
Kitchen = grp.getvalue('1/4/4') --'0 Verl. Kitchen (tm)'
ontime_Kitchen = 'ontime_kitchen'
output_Kitchen = '32/1/202' --'Kitchen [timer on]'
if Kitchen then
if not storage.get(ontime_Kitchen) then
storage.set(ontime_Kitchen, os.time())
grp.update(output_Kitchen, '0 m')
end
else
storage.delete(ontime_Kitchen)
grp.update(output_Kitchen, '')
end
Code:
ontime_Kitchen = 'ontime_kitchen'
output_Kitchen = '32/1/202' --'Kitchen [timer on]'
time = storage.get(ontime_Kitchen)
if time then
delta = os.time() - time
minutes = math.floor(delta / 60)
hours = math.floor(minutes / 60)
minutes = minutes % 60
if hours > 0 then
res = hours .. 'h '
else
res = ''
end
res = res .. minutes2 .. ' minuten'
grp.update(output_Kitchen, res)
end
If using multiple timers you can combine the scheduled/resident scripts into one.