09.02.2024, 08:59
(23.08.2023, 13:43)Daniel Wrote: Try this, change test2 to your trend name.I modify the script :
Code:require('trends')
-- get data for the past day
dates = {}
dates['start'] = os.date('*t')
dates['start'].day = dates['start'].day - 1
dates['end'] = os.date('*t')
-- fetch previous value
day = trends.fetch('test2', dates)
rain=0
-- for i = START, STOP, STEP
for i = 1, 48, 1 do
rain=rain + day[i]
end
log(rain)
-- Verifico numeri quarti d'ora di pioggia ultime 24 ore
require('trends')
-- Prelevo i dati ultime 24 ore
dates = {}
dates['start'] = os.date('*t')
dates['start'].day = dates['start'].day - 1
dates['end'] = os.date('*t')
-- fetch previous value
day = trends.fetch('Andamento_pioggia', dates)
rain=0
-- for i = START, STOP, STEP
for i = 1, 48, 1 do
rain=rain + day[i]
end
grp.write('0/2/226',rain)
log(rain)
The trend this morning is:
from 0 to 9.45 all 15 minutes the trend it's 1, but the rain indicate 0.
What's the mistake?