10.05.2021, 11:58
Hi.
Now that i have somewhat control over how to POST to the API, i'm having problems understanding how to use GET from the API. I have made a Resident script with 2 sec. sleep interval. The goal is to retrive volume % status on my HifiBerry amplifier, and write it to a group adress.
The code above is a mess. Any ideas how to do this?
Now that i have somewhat control over how to POST to the API, i'm having problems understanding how to use GET from the API. I have made a Resident script with 2 sec. sleep interval. The goal is to retrive volume % status on my HifiBerry amplifier, and write it to a group adress.
Code:
http = require('socket.http')
ltn12 = require('ltn12')
Volume_status = grp.find ('25/2/12')
--body = require('json').encode({
-- percent = tostring(event.getvalue())
--})
res, code = http.request({
url = 'http://192.168.1.91:81/api/volume',
method = 'GET',
headers = {
['Content-Length'] = #body,
['Content-Type'] = 'application/json',
},
source = ltn12.source.string(body)
})
Volume_status :write(GET_Volume)
log(res, code)
The code above is a mess. Any ideas how to do this?
BR
Kai-Roger
Kai-Roger