Trend accumulate option - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9) +--- Thread: Trend accumulate option (/showthread.php?tid=592) Trend accumulate option - PassivPluss - 05.02.2017 Hi. When creating a trend there should be an option to choose between accumulate values or use average values. When trending a temperature it would be best to use average( this is the only option today) when trending kwh accumulate would be best. When changing view of the trend (day by day, or week by week) the trend value can be correct. Now I have to multiply the value by 24 if it is day by day and so on. RE: Trend accumulate option - Erwin van der Zwart - 05.02.2017 Hi, You already can... use absolute value for average and counter for cumulative. BR, Erwin RE: Trend accumulate option - PassivPluss - 05.02.2017 I tried counter a couple of years ago but that made no sense with the values. I can try again to see. RE: Trend accumulate option - Erwin van der Zwart - 05.02.2017 Hi, Can be, currently i don't see any issue with trends. There is a lot changed the last years (: For kWh i advice mostly to make even 2 trends on same object, 1 absolute to see average consumption and 1 counter to see total (however this is a straight line upwards). Make sure to use counter only for values that are not getting lower then the previous value (temperature or kW is not a real good idea to use counter, this results in wrong trends) Kwh can be used as counter. BR, Erwin RE: Trend accumulate option - PassivPluss - 05.02.2017 Aha. My measuring is based on Watts x Ampere which gives me Kw realtime. I dont want a counter as that gives a line up as you say. I just want an accumulate of the seperate values to get a trend. It is not possible to se previous trend and compare it to current if the values are unlike as the line up counter will do. If I have 1 hour trend and chose to se day by day, i would likr the lm to add up all the 24 points and give me the total for each day RE: Trend accumulate option - Erwin van der Zwart - 05.02.2017 Okay new approach (: Well what you could do in this case is create a dummy object and create a trend to this dummy object and create a scheduled script that runs once a day at 0:01. (or run every x minutes if you want multiple points in between) In this scheduled script you do a trends.fetchone on the trend with the 24 points, this will give you a average day value of your day values. Write this result once a day to your dummy object and the second trend attached to the dummy object will show your day average value(s). If you want a total sum of the day values you can do a trend.fetch (instead of the fetchone) this will result in a data set of the full day and do a loop through the result table to sum all values and write the sum result to your dummy object, this results in a trend with sum of day values. See http://openrb.com/docs/trends-new.htm for a sample how to fetch one average day value or a table with day values where you can loop through to sum up the day values. BR, Erwin RE: Trend accumulate option - admin - 06.02.2017 Trends are not meant for realtime values. It will produce incorrect data because the lowest possible sampling time is 5 minutes. You can create a script which acts as a counter and adds the current consumption value to an object which is then added as a trend with counter type. RE: Trend accumulate option - PassivPluss - 06.02.2017 When you write that the sampling time is 5 min i suppose you mean that the trend values is an average of the 5 minutes? Not just a reading that takes place every 5 minutes? RE: Trend accumulate option - admin - 06.02.2017 The object value is read every 5 minutes, so everything else in between is lost. That's why you should not use it for realtime data without extra processing beforehand. RE: Trend accumulate option - PassivPluss - 06.02.2017 Ok. I was not aware of that. This means that trending of anything that changes rapidly is not incorrect. What should i do to get it to be more accurate? The best would be to take a sample every minute and then use the 5 values to make one 5 minute sample. Or 10 to make 10 min sample. Is this possible and then make a trend with the data? RE: Trend accumulate option - fabiorusco - 23.08.2023 Hallo, I need know how time it's rained in the last 24 hours (for garden irrigation), I thinked to use the trend about rain address of weather station, with 15 minutes of perdiod. I need keep continuosly only the last 48 sample and sum all the values (FIFO). If the result is more then 24 I don't start the irrigation. How I can do it? Thank you and best regards. Fabio Rusconi RE: Trend accumulate option - Daniel - 23.08.2023 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)``` RE: Trend accumulate option - fabiorusco - 09.02.2024 (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?     RE: Trend accumulate option - Daniel - 09.02.2024 What type of trend do you use? RE: Trend accumulate option - fabiorusco - 09.02.2024 (09.02.2024, 09:03)Daniel Wrote: What type of trend do you use?see attacched:     RE: Trend accumulate option - fabiorusco - 28.02.2024 Hallo, someone can help me, please. Fabio RE: Trend accumulate option - Daniel - 28.02.2024 Log the object to see what value it actually is. Manually change it to 0 if is 1. RE: Trend accumulate option - fabiorusco - 04.09.2024 Hallo, I understad the problem: the trend.fetch use the start time at 0 hour and 0 minutes. I need that the start time will be the same of the time that run the script (the day will be the day before). Othewise I have the number of slot with rain of the last day and not in the last 24 hours. It's possible solve the problem? Best regards RE: Trend accumulate option - admin - 04.09.2024 See this thread: https://forum.logicmachine.net/showthread.php?tid=5475