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 Log functions question
#2
What do you mean that "the values doesn't make much sense"? Are they different from the data view in trends UI monthly mode?

This example exports daily data for multiple trends for the past month. You can add more trend name to the trendlist table as needed.
Code:
require('trends') trendlist = {   'Temperature',   'Humidity', } now = os.date('*t') dates = {   ['start'] = { year = now.year, month = now.month - 1, day = 1 },   ['end'] = { year = now.year, month = now.month, day = 1 } } if dates.start.month == 0 then   dates.start.month = 12   dates.start.year = dates.start.year - 1 end year, month = dates.start.year, dates.start.month rows = {} datas = {} days = 0 row = { '""' } for _, name in ipairs(trendlist) do   data = trends.fetch(name, dates, 86400) or {}   days = math.max(days, #data)   datas[ #datas + 1 ] = data   row[ #row + 1 ] = string.format('%q', name) end rows[ #rows + 1 ] = table.concat(row, ',') for day = 1, days do   row = {}   row[ #row + 1 ] = string.format('%d.%02d.%02d', year, month, day)   for _, data in ipairs(datas) do     row[ #row + 1 ] = data[ day ] or ''   end   rows[ #rows + 1 ] = table.concat(row, ',') end csv = table.concat(rows, '\r\n')
Reply


Messages In This Thread
Trend Log functions question - by iJAF - 05.07.2022, 16:24
RE: Trend Log functions question - by admin - 06.07.2022, 08:59
RE: Trend Log functions question - by iJAF - 06.07.2022, 10:43

Forum Jump: