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.

Trend accumulate option
#20
(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?
Reply


Messages In This Thread
Trend accumulate option - by PassivPluss - 05.02.2017, 18:34
RE: Trend accumulate option - by PassivPluss - 05.02.2017, 19:02
RE: Trend accumulate option - by PassivPluss - 05.02.2017, 20:37
RE: Trend accumulate option - by admin - 06.02.2017, 07:37
RE: Trend accumulate option - by PassivPluss - 06.02.2017, 12:48
RE: Trend accumulate option - by admin - 06.02.2017, 12:50
RE: Trend accumulate option - by PassivPluss - 06.02.2017, 14:42
RE: Trend accumulate option - by fabiorusco - 23.08.2023, 12:45
RE: Trend accumulate option - by Daniel - 23.08.2023, 13:43
RE: Trend accumulate option - by fabiorusco - 09.02.2024, 08:59
RE: Trend accumulate option - by Daniel - 09.02.2024, 09:03
RE: Trend accumulate option - by fabiorusco - 09.02.2024, 10:19
RE: Trend accumulate option - by fabiorusco - 28.02.2024, 13:59
RE: Trend accumulate option - by Daniel - 28.02.2024, 14:03
RE: Trend accumulate option - by fabiorusco - 04.09.2024, 14:33
RE: Trend accumulate option - by admin - 04.09.2024, 14:35
RE: Trend accumulate option - by fabiorusco - 20.09.2024, 11:51
RE: Trend accumulate option - by admin - 20.09.2024, 11:55
RE: Trend accumulate option - by fabiorusco - 20.09.2024, 12:44
RE: Trend accumulate option - by admin - 20.09.2024, 12:46
RE: Trend accumulate option - by fabiorusco - 20.09.2024, 12:57
RE: Trend accumulate option - by admin - 20.09.2024, 12:58
RE: Trend accumulate option - by fabiorusco - 20.09.2024, 13:25

Forum Jump: