19.04.2022, 07:02
Code:
json = require('json')
http = require('socket.http')
ltn12 = require('ltn12')
url = 'https://developer-api.govee.com/v1/devices/control'
key = '00000000-729c-4b82-b536-000000000'
body = json.encode({
device = '34:20:03:15:82:ae',
model = 'H6089',
cmd = {
name = 'turn',
value = 'on'
}
})
resp = {}
res, code = http.request({
url = url,
method = 'PUT',
headers = {
['Content-Type'] = 'application/json',
['Content-Length'] = #body,
['Govee-API-Key'] = key,
},
source = ltn12.source.string(body),
sink = ltn12.sink.table(resp),
})
log(res, code, resp)