Logic Machine Forum
Problem with Trend API - Printable Version

+- Logic Machine 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: Problem with Trend API (/showthread.php?tid=553)



Problem with Trend API - buuuudzik - 14.01.2017

I want use trends for energy calculation last day, last month, last year.

Probably I've found a bug in a firmware 20160927 or I don't understand well this API.

Trend 'Light' has resolution 10 minutes. I want receive table with 24 x 1-hour data, but by this script I receive only table with 144 keys(every 10 minutes). The other situation is when I use only 86400 then I receive 1 value. When I use 86400/2 or 86400/4 or other there is everytime table with 144 keys(every 10 minutes).

Code:
require('trends')
name = 'Light'
dates = {}
dates['start'] = { year = 2017, month = 1, day = 12}
dates['end'] = { year = 2017, month = 1, day = 13}
-- resolution (in seconds) is optional
-- default trend resolution is used when not set
resolution = 3600 -- hourly data
res = trends.fetch(name, dates, resolution)

log(res)



RE: Problem with Trend API - admin - 16.01.2017

Trends API is mostly low-level stuff, so you can either get data at selected trend resolution or daily data. Everything else must be converted manually.