21.10.2024, 08:36
Thanks for quick answer. Time Zone is Europe/Madrid. Here is the code
https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')
token = '***********************'
--tuya
tbl = {}
res, code = https.request({
url = 'https://openapi.tuyaeu.com/v1.0/devices/***8dc756f81122a3al***/status',
method = 'GET',
headers = {
['authorization'] = 'Bearer ' .. token,
['content-type'] = 'application/json',
},
sink = ltn12.sink.table(tbl),
})
log(os.date('%c'))
if res and code == 200 then
resp = table.concat(tbl)
resp = json.pdecode(resp)
log(resp)
else
log(res, code)
end
https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')
token = '***********************'
--tuya
tbl = {}
res, code = https.request({
url = 'https://openapi.tuyaeu.com/v1.0/devices/***8dc756f81122a3al***/status',
method = 'GET',
headers = {
['authorization'] = 'Bearer ' .. token,
['content-type'] = 'application/json',
},
sink = ltn12.sink.table(tbl),
})
log(os.date('%c'))
if res and code == 200 then
resp = table.concat(tbl)
resp = json.pdecode(resp)
log(resp)
else
log(res, code)
end