![]() |
|
Trend evaluation - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Trend evaluation (/showthread.php?tid=5157) |
Trend evaluation - stephan - 15.12.2023 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. RE: Trend evaluation - admin - 15.12.2023 See examples here: https://kb.logicmachine.net/libraries/trends/#examples https://forum.logicmachine.net/showthread.php?tid=771&pid=4484#pid4484 RE: Trend evaluation - stephan - 15.12.2023 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 RE: Trend evaluation - admin - 15.12.2023 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)RE: Trend evaluation - stephan - 15.12.2023 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 |