This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Trends_Log
#12
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)
Reply


Messages In This Thread
Trends_Log - by Rodriguez - 03.05.2017, 19:40
RE: Trends_Log - by buuuudzik - 04.05.2017, 12:09
RE: Trends_Log - by Rodriguez - 04.05.2017, 13:22
RE: Trends_Log - by buuuudzik - 04.05.2017, 14:09
RE: Trends_Log - by Rodriguez - 05.05.2017, 13:13
RE: Trends_Log - by buuuudzik - 05.05.2017, 13:21
RE: Trends_Log - by Rodriguez - 05.05.2017, 16:26
RE: Trends_Log - by buuuudzik - 05.05.2017, 17:01
RE: Trends_Log - by Rodriguez - 07.05.2017, 01:28
RE: Trends_Log - by buuuudzik - 07.05.2017, 06:26
RE: Trends_Log - by Rodriguez - 08.05.2017, 16:07
RE: Trends_Log - by buuuudzik - 08.05.2017, 19:37

Forum Jump: