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 PassivPluss Member Posts: 176 Threads: 42 Joined: Jul 2015 Reputation: 2 05.02.2017, 18:34 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. Erwin van der Zwart Senior Member Posts: 1756 Threads: 6 Joined: Jul 2015 Reputation: 115 05.02.2017, 18:59 Hi, You already can... use absolute value for average and counter for cumulative. BR, Erwin PassivPluss Member Posts: 176 Threads: 42 Joined: Jul 2015 Reputation: 2 05.02.2017, 19:02 I tried counter a couple of years ago but that made no sense with the values. I can try again to see. Erwin van der Zwart Senior Member Posts: 1756 Threads: 6 Joined: Jul 2015 Reputation: 115 05.02.2017, 19:17 (This post was last modified: 05.02.2017, 19:33 by Erwin van der Zwart.) 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 PassivPluss Member Posts: 176 Threads: 42 Joined: Jul 2015 Reputation: 2 05.02.2017, 20:37 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 Erwin van der Zwart Senior Member Posts: 1756 Threads: 6 Joined: Jul 2015 Reputation: 115 05.02.2017, 23:23 (This post was last modified: 06.02.2017, 00:26 by Erwin van der Zwart.) 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 admin Administrator Posts: 7584 Threads: 41 Joined: Jun 2015 Reputation: 439 06.02.2017, 07:37 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. PassivPluss Member Posts: 176 Threads: 42 Joined: Jul 2015 Reputation: 2 06.02.2017, 12:48 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? admin Administrator Posts: 7584 Threads: 41 Joined: Jun 2015 Reputation: 439 06.02.2017, 12:50 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. PassivPluss Member Posts: 176 Threads: 42 Joined: Jul 2015 Reputation: 2 06.02.2017, 14:42 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? fabiorusco Junior Member Posts: 45 Threads: 3 Joined: May 2018 Reputation: 0 23.08.2023, 12:45 (This post was last modified: 23.08.2023, 12:49 by fabiorusco.) 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 Daniel Administrator Posts: 4416 Threads: 21 Joined: Aug 2017 Reputation: 196 23.08.2023, 13:43 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)``` ------------------------------ Ctrl+F5 fabiorusco Junior Member Posts: 45 Threads: 3 Joined: May 2018 Reputation: 0 09.02.2024, 08:59 (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?     Daniel Administrator Posts: 4416 Threads: 21 Joined: Aug 2017 Reputation: 196 09.02.2024, 09:03 What type of trend do you use? ------------------------------ Ctrl+F5 fabiorusco Junior Member Posts: 45 Threads: 3 Joined: May 2018 Reputation: 0 09.02.2024, 10:19 (09.02.2024, 09:03)Daniel Wrote: What type of trend do you use?see attacched:     fabiorusco Junior Member Posts: 45 Threads: 3 Joined: May 2018 Reputation: 0 28.02.2024, 13:59 Hallo, someone can help me, please. Fabio Daniel Administrator Posts: 4416 Threads: 21 Joined: Aug 2017 Reputation: 196 28.02.2024, 14:03 Log the object to see what value it actually is. Manually change it to 0 if is 1. ------------------------------ Ctrl+F5 fabiorusco Junior Member Posts: 45 Threads: 3 Joined: May 2018 Reputation: 0 04.09.2024, 14:33 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 admin Administrator Posts: 7584 Threads: 41 Joined: Jun 2015 Reputation: 439 04.09.2024, 14:35 See this thread: https://forum.logicmachine.net/showthread.php?tid=5475 « Next Oldest | Next Newest »

Forum Jump: