20.09.2024, 11:51
(04.09.2024, 14:35)admin Wrote: See this thread: https://forum.logicmachine.net/showthread.php?tid=5475
Code:
require('trends')
-- get data for the past day
date = os.date('*t')
time = os.time(date, true) -- UTC timestamp
log(time)
datarange = {
['start'] = time - 86400,
['end'] = time,
}
log(datarange)
alert('passo 0')
-- fetch previous value
day = trends.fetch('Andamento_Pioggia_Valore_Unico', datarange, 900, true)
log(day)
alert('passo a')
rain=0
-- for i = START, STOP, STEP
for i = 1, 96, 1 do
rain=rain + day[i]
end
alert('passo b')
log(rain)
I want, in the last 24 hours, steps are 15 min (900 sec), read in how many quarter of hour have rain. With the script above alert '(passo a') don't is showed. Can someone tell where is my mistake please?