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
#13
(23.08.2023, 13:43)Daniel Wrote: Try this, change test2 to your trend name.
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)
I modify the script :
-- 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?    
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

Forum Jump: