22.01.2025, 21:00
Is this method working anymore?
My script suddenly stopped working 8 jan.
i now returns code 400
My script suddenly stopped working 8 jan.
i now returns code 400
Code:
os.sleep(1)
https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')
token = '5K4MVS-OjfWhK_4yrjOlFe1F6kJXPVf7eQYggo8ebAE' -- demotoken
data = json.encode({
query = '{viewer {homes {currentSubscription {priceInfo}}}}' --kwh pris med avgifter
})
tbl = {}
res, code = https.request({
url = 'https://api.tibber.com/v1-beta/gql',
method = 'POST',
headers = {
['authorization'] = 'Bearer ' .. token,
['content-type'] = 'application/json',
['content-length'] = #data,
},
source = ltn12.source.string(data),
sink = ltn12.sink.table(tbl),
})
if res and code == 200 then
resp = table.concat(tbl)
resp = json.pdecode(resp)
homes = resp.data.viewer.homes
info = homes[ 1 ].currentSubscription.priceInfo.current
log(res, code, info.total, info.level)
grp.write('33/0/51', info.total*100)
grp.write('33/0/53', info.level)
else
log(res, code, homes, info)
end