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.

energy data
#1
How can I retrieve the energy consumption curve data? 
I have created curves for energy consumption ( kWh in counter mode ) and i would like to display daily consumption as well as the consumption for the past 3 days. I would also like to do the same for months and years."

I have this script but only day work 


require('trends')

os_date = os.date("*t")
os_end_date = {
  year = os_date.year,
  month = os_date.month,
  day = os_date.day + 1
  }
 

dates = {
  ['start'] = { year = os_date.year, month = os_date.month, day = os_date.day },
  ['end'] = { year = os_end_date.year, month = os_end_date.month, day = os_end_date.day },
}
--log(dates)
 
-- fetch current value
day = trends.fetchone(' Main ', dates)
--log(day)
grp.update('2/1/1', day)

month = trends.fetch(' Main ', dates)
--log(month)
grp.update('2/1/2', month)
Reply
#2
Check this thread: https://forum.logicmachine.net/showthread.php?tid=4202
Example of loading trends data from Custom JS: https://forum.logicmachine.net/showthrea...7#pid34287
Reply
#3
(21.03.2024, 08:49)admin Wrote: Check this thread: https://forum.logicmachine.net/showthread.php?tid=4202
Example of loading trends data from Custom JS: https://forum.logicmachine.net/showthrea...7#pid34287
 thx 

Do you know why my script don't work for month ?
Reply
#4
You need to specify a different date period to get monthly data:
Code:
dates = {}
dates['start'] = os.date('*t')
dates['start'].month = dates['start'].month - 1
dates['end'] = os.date('*t')

month = trends.fetchone(' MAIN ', dates)

Example for yearly data: https://kb.logicmachine.net/libraries/trends/#examples
Reply


Forum Jump: