20.11.2015, 11:16
Here's an example for creating trends, don't forget to set admin password in socket.http.request:
Code:
require('json')
require('socket.url')
require('socket.http')
object = '1/1/1'
trend = {
object = knxlib.encodega(object),
name = 'New trend', -- trend name
type = 'C', -- C is counter, D is counter with neg. delta, G is absolute value
precision = 2, -- floating point precision
count_minutely = 24 * 60, -- 1 day
count_hourly = 24 * 365, -- 1 year
count_daily = 365, -- 1 year
}
data = json.encode(trend)
post = 'data=' .. socket.url.escape(data)
res, err = socket.http.request('http://admin:admin@127.0.0.1/cgi-bin/scada/general/request.cgi?_module=trends&_action=save', post)
log(res, err)