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 evaluation
#1
Hello,
 I would like to automatically evaluate my trend recording. I have a consumption counter that is reset daily at 0:00. I would like to have an evaluation on which day was the highest consumption and the consumption value.
Reply
#2
See examples here:
https://kb.logicmachine.net/libraries/trends/#examples
https://forum.logicmachine.net/showthrea...84#pid4484
Reply
#3
Not quite what I'm looking for, I just want to get the day with the highest value.

day 1 5kw, day 2 7kw, day 3 6 Kw, day 4 10 Kw, day 5 3 kw etc., should then show me that day 4 with 10kw was the highest value
Reply
#4
This will log the highest value and respective date for the past 7 days.
Code:
daycount = 7
trendname = 'TEMP'

dates = {}
dates['start'] = os.date('*t')
dates['start'].day = dates['start'].day - daycount
dates['end'] = os.date('*t')

values = require('trends').fetch(trendname, dates, 86400, true)

table.sort(values, function(a, b)
  return a[2] > b[2]
end)

max = values[ 1 ]
time, value = unpack(max)
date = os.date('%F', time)

log(date, value)
Reply
#5
I have now solved it like this, I get the value as a KNX object

if event.getvalue() > grp.getvalue('55/0/4') then
grp.update('55/0/4', event.getvalue())
grp.update('55/0/5', os.date(' %A %d %B %H:%M '))
end
Reply


Forum Jump: