03.04.2023, 08:58
Use this to get JSON data, change token and url as needed:
You can store time/value pairs in storage and use a scheduled script that checks if any event should run once a minute.
Code:
json = require('json')
ltn12 = require('ltn12')
http = require('socket.http')
token = 'ABCDEF'
url = 'https://httpbin.org/get'
resp = {}
res, code = http.request({
url = url,
method = 'GET',
headers = {
authorization = 'Bearer ' .. token,
},
sink = ltn12.sink.table(resp),
})
resp = table.concat(resp)
resp = json.pdecode(resp)
log(resp)
You can store time/value pairs in storage and use a scheduled script that checks if any event should run once a minute.