17.06.2022, 14:26
(17.06.2022, 14:15)admin Wrote: What do you get logged from this script?
Code:require('socket.http')
log(socket.http.request('http://127.0.0.1/'))
Here is the whole script:
Code:
require('json')
require('socket.url')
require('socket.http')
user = 'admin'
Password = 'Ringshusveien_18'
tag = 'nyTrend'
-- parameters
daily = 365*24*60 -- 1 day
daily1year = 365*24*12 -- 365 day
daily2year = 2*365*24*12 -- 365 day
year5_d = 5*365 -- 5 year
obj = grp.tag(tag)
for _, addr in ipairs(obj) do
object = addr.address
alias = addr.name
trend = {
object = knxlib.encodega(object), -- object id in db
name = alias, -- trend name
type = trend_type,
resolution = 5, -- every 5 minute
precision = 2, -- floating point precision
count_resolution = 365*24*12, -- 1 year
count_daily = 5*365 -- 5 years
}
data = json.encode(trend)
post = 'data=' .. socket.url.escape(data)
grp.removetags(addr.name, tag)
res, err = socket.http.request('http://' .. user .. ':' .. password .. '@127.0.0.1/scada-main/trends/save', post)
log(res, err)
end
script.disable(_SCRIPTNAME)
I am basically logging the result and errors from the saving of the trend.
There are 10 kinds of people in the world; those who can read binary and those who don't