07.01.2023, 17:28
(05.01.2023, 08:13)admin Wrote: The second script starting with "value = event.getvalue()" must be an event script (script that is triggered by an object value change).
With your indications it works more or less for me;(, group time counter is set to 0, but the one that would have to be maintained and continue subtracting also goes to 0
-
Code:
value = event.getvalue('32/7/9')
key_curr = 'ontime_curr'
out_curr = '33/1/30 ' -- Time on Grupo Electrogeno
key_total = 'ontime_total'
out_total = '33/1/31' -- Total on time de Encendido Grupo Electrogeno
time = storage.get(key_curr)
now = os.time()
if value then
if not time then
storage.set(key_curr, now)
formattime(out_curr, 0)
end
else
if time then
time_total = storage.exec('incrby', key_total)
storage.delete(key_curr)
end
grp.update(out_curr, '')
end
-
Code:
key_curr = 'ontime_curr'
out_curr = '33/1/30'
key_total = 'ontime_total'
out_total = '33/1/31'
time_curr = storage.get(key_curr)
if time_curr then
time_curr = os.time() - time_curr
formattime(out_curr, time_curr)
time_total = 22 * 3600 -- 22 hours in seconds
time_remaining = math.max(0,time_total - time_curr)
formattime(out_total, time_remaining)
end
Thank you