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
#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


Messages In This Thread
Trends API - by buuuudzik - 28.05.2016, 16:52
RE: Trends API - by Habib - 28.05.2016, 17:13
RE: Trends API - by Erwin van der Zwart - 28.05.2016, 22:01
RE: Trends API - by admin - 29.05.2016, 06:12
RE: Trends API - by buuuudzik - 29.05.2016, 11:22
RE: Trends API - by Erwin van der Zwart - 02.09.2016, 18:46
RE: Trends API - by admin - 05.09.2016, 06:01
RE: Trends API - by Erwin van der Zwart - 05.09.2016, 09:29
RE: Trends API - by Pawel - 07.12.2016, 20:15
RE: Trends API - by Domoticatorino - 19.02.2018, 15:39
RE: Trends API - by Erwin van der Zwart - 19.02.2018, 16:32
RE: Trends API - by Domoticatorino - 13.02.2018, 16:52
RE: Trends API - by Daniel - 13.02.2018, 18:49
RE: Trends API - by Domoticatorino - 19.02.2018, 16:33
RE: Trends API - by PassivPluss - 17.09.2019, 21:10
RE: Trends API - by admin - 24.09.2019, 06:53
RE: Trends API - by Trond Hoyem - 17.06.2022, 12:57
RE: Trends API - by admin - 17.06.2022, 13:20
RE: Trends API - by Trond Hoyem - 17.06.2022, 13:23
RE: Trends API - by admin - 17.06.2022, 13:23
RE: Trends API - by Trond Hoyem - 17.06.2022, 13:27
RE: Trends API - by admin - 17.06.2022, 13:30
RE: Trends API - by Trond Hoyem - 17.06.2022, 13:33
RE: Trends API - by admin - 17.06.2022, 13:34
RE: Trends API - by Trond Hoyem - 17.06.2022, 13:36
RE: Trends API - by admin - 17.06.2022, 14:15
RE: Trends API - by Trond Hoyem - 17.06.2022, 14:26
RE: Trends API - by admin - 17.06.2022, 14:32

Forum Jump: