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.

http request json (dxsEntries) Kostal
#1
I need help. I don't know what I'm doing wrong to put the value in a group address.

Thanks for your help






Code:
require('json')
http = require('socket.http')
require('socket.url')

url= 'http://192.168.2.11/api/dxs.json?dxsEntries=33556229'

url = string.format(url)
                                                                                 

res = http.request(url)

data = json.pdecode(res)
if type(data) ~= 'table' then
alert('failed to load data')
  return
end

if data.error then
  log('error', data.error)
  return
end


dxsEntries = data.dxsEntries
log(dxsEntries)

grp.write('32/4/10', dxsEntries.value)                                                                                                       






Reply
#2
Try this:
Code:
require('json')
http = require('socket.http')

url= 'http://192.168.2.11/api/dxs.json?dxsEntries=33556229'
res = http.request(url)

data = json.pdecode(res)
if type(data) ~= 'table' then
  alert('failed to load data')
  return
end

if data.error then
  log('error', data.error)
  return
end

dxsEntries = data.dxsEntries[1] -- first array/table element
log(dxsEntries)

grp.checkwrite('32/4/10', dxsEntries.value)
Reply


Forum Jump: