08.05.2017, 19:37
This is little example for calculating average value:
Code:
require('trends')
-- get data for the last day from 00:00 to 23:59
dates = {}
dates['start'] = os.date('*t')
dates['start'].day = dates['start'].day - 1
dates['end'] = os.date('*t')
-- fetch previous value
daily = trends.fetch('Wind', dates)
sum = 0
for k,v in ipairs(daily) do
sum = sum + v
end
average = sum/(#daily)
log(average)