22.07.2024, 08:18
Try this:
Code:
token = 'abcdef'
url = 'http://192.168.1.1/api/v2/latestdata'
resp, code, hdrs, stat = require('socket.http').request({
url = url,
method = 'GET',
headers = {
['Auth-Token'] = token
},
})
if code == 200 then
data = require('json').pdecode(resp)
log(data)
consumption = data['Consumption_W']
production = data['Production_W']
state = data['ic_status']['statebms']
log(consumption, production, state)
else
log('request failed', resp, code)
end