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.

Deconz REST API
#4
Hi again.

I tried to use a variable (Percent) inside the Json expression in the "body". This does not work. Any tips on how to do this?


Code:
Percent    = event.getvalue    ()

http = require('socket.http')
ltn12 = require('ltn12')

--body = '{"lift":100}'
body = '{"lift":Percent}'


res, code = http.request({
  url = 'http://192.168.1.80:40850/api/8EBFA5778F/lights/2/state/',
  method = 'PUT',
  headers = {
    ['Content-Length'] = #body,
  },
  source = ltn12.source.string(body)
})

log(res, code)
BR
Kai-Roger
Reply


Messages In This Thread
Deconz REST API - by Kai-Roger - 18.04.2021, 17:54
RE: Deconz REST API - by admin - 19.04.2021, 06:31
RE: Deconz REST API - by Kai-Roger - 19.04.2021, 21:34
RE: Deconz REST API - by Kai-Roger - 20.04.2021, 06:14
RE: Deconz REST API - by admin - 20.04.2021, 06:24
RE: Deconz REST API - by Kai-Roger - 20.04.2021, 16:07

Forum Jump: