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.

Trends API
#21
(17.06.2022, 13:23)admin Wrote: Not 120 but 127.0.0.1

You are right. The typo is only in the previous post, the address in the script is 127.0.0.1.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#22
The error comes from having @ symbol in the password. It confuses the URL parser. Try using a password without @.
Reply
#23
(17.06.2022, 13:30)admin Wrote: The error comes from having @ symbol in the password. It confuses the URL parser. Try using a password without @.

Yes, I saw that as well, so I have changed the password so that there is no @ any more. 

I now get "timeout" in stead of "host not found"
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#24
The IP blocker might have blocked local access because of wrong password. Reboot the device and try again.
Reply
#25
(17.06.2022, 13:34)admin Wrote: The IP blocker might have blocked local access because of wrong password. Reboot the device and try again.

I have also tried that. I actually down-powered it and repowered. Still same timeout.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#26
What do you get logged from this script?
Code:
require('socket.http')
log(socket.http.request('http://127.0.0.1/'))
Reply
#27
(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  Cool
Reply
#28
Works for me. Try running script from my previous post and see what you get in Logs.
Your script is also missing trend_type variable. It should be either 'C', 'D' or 'G' (counter, counter with negative delta or absolute value respectively).
Reply


Forum Jump: