09.08.2021, 21:08
Trying to wrap my head around to get the data out from my logs and howto extract the data and to write them into groupaddresses
I see the data in scriptlogs, but can't find out howto extract the 24 hours values into seperate GA's
My script:
Results from my scriptlog:
Tibber API 09.08.2021 22:54:24
* table:
[1]
* table:
["currentSubscription"]
* table:
["priceInfo"]
* table:
["today"]
* table:
[1]
* table:
["startsAt"]
* string: 2021-08-09T00:00:00+02:00
["total"]
* number: 0.7054
[2]
* table:
["startsAt"]
* string: 2021-08-09T01:00:00+02:00
["total"]
* number: 0.6915
[3]
* table:
["startsAt"]
* string: 2021-08-09T02:00:00+02:00
["total"]
* number: 0.5271
[4]
* table:
["startsAt"]
* string: 2021-08-09T03:00:00+02:00
["total"]
* number: 0.4968
[5]
* table:
["startsAt"]
* string: 2021-08-09T04:00:00+02:00
["total"]
* number: 0.7097
[6]
* table:
["startsAt"]
* string: 2021-08-09T05:00:00+02:00
["total"]
* number: 0.7656
[7]
* table:
["startsAt"]
* string: 2021-08-09T06:00:00+02:00
["total"]
* number: 0.8536
[8]
* table:
["startsAt"]
* string: 2021-08-09T07:00:00+02:00
["total"]
* number: 0.8735
[9]
* table:
["startsAt"]
* string: 2021-08-09T08:00:00+02:00
["total"]
* number: 0.8917
[10]
* table:
["startsAt"]
* string: 2021-08-09T09:00:00+02:00
["total"]
* number: 0.8721
[11]
* table:
["startsAt"]
* string: 2021-08-09T10:00:00+02:00
["total"]
* number: 0.8418
[12]
* table:
["startsAt"]
* string: 2021-08-09T11:00:00+02:00
["total"]
* number: 0.8247
[13]
* table:
["startsAt"]
* string: 2021-08-09T12:00:00+02:00
["total"]
* number: 0.8182
[14]
* table:
["startsAt"]
* string: 2021-08-09T13:00:00+02:00
["total"]
* number: 0.8108
[15]
* table:
["startsAt"]
* string: 2021-08-09T14:00:00+02:00
["total"]
* number: 0.8135
[16]
* table:
["startsAt"]
* string: 2021-08-09T15:00:00+02:00
["total"]
* number: 0.8085
[17]
* table:
["startsAt"]
* string: 2021-08-09T16:00:00+02:00
["total"]
* number: 0.8252
[18]
* table:
["startsAt"]
* string: 2021-08-09T17:00:00+02:00
["total"]
* number: 0.9003
[19]
* table:
["startsAt"]
* string: 2021-08-09T18:00:00+02:00
["total"]
* number: 0.9642
[20]
* table:
["startsAt"]
* string: 2021-08-09T19:00:00+02:00
["total"]
* number: 0.9705
[21]
* table:
["startsAt"]
* string: 2021-08-09T20:00:00+02:00
["total"]
* number: 0.9249
[22]
* table:
["startsAt"]
* string: 2021-08-09T21:00:00+02:00
["total"]
* number: 0.913
[23]
* table:
["startsAt"]
* string: 2021-08-09T22:00:00+02:00
["total"]
* number: 0.887
[24]
* table:
["startsAt"]
* string: 2021-08-09T23:00:00+02:00
["total"]
* number: 0.8531
Scripts errorlog:
Tibber API 09.08.2021 22:55:24
Resident script:29: attempt to index global 'homes' (a nil value)
stack traceback:
Any hints howto proceed?
I wan't to have hourvalue 0-1 in GA 33/0/0, hourvalue 1-2 in GA 33/0/1 and so on...
BR, Odd Egil
I see the data in scriptlogs, but can't find out howto extract the 24 hours values into seperate GA's
My script:
Code:
https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')
token = 'MYTOKEN'
data = json.encode({
query = '{viewer {homes {currentSubscription {priceInfo {today {total startsAt }}}}}}'
})
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)
log(resp.data.viewer.homes)
info = homes[1].currentSubscription.priceInfo.today[1].total
-- Value for hour 0-1
grp.write('33/0/0', info.total*100)
end
Results from my scriptlog:
Tibber API 09.08.2021 22:54:24
* table:
[1]
* table:
["currentSubscription"]
* table:
["priceInfo"]
* table:
["today"]
* table:
[1]
* table:
["startsAt"]
* string: 2021-08-09T00:00:00+02:00
["total"]
* number: 0.7054
[2]
* table:
["startsAt"]
* string: 2021-08-09T01:00:00+02:00
["total"]
* number: 0.6915
[3]
* table:
["startsAt"]
* string: 2021-08-09T02:00:00+02:00
["total"]
* number: 0.5271
[4]
* table:
["startsAt"]
* string: 2021-08-09T03:00:00+02:00
["total"]
* number: 0.4968
[5]
* table:
["startsAt"]
* string: 2021-08-09T04:00:00+02:00
["total"]
* number: 0.7097
[6]
* table:
["startsAt"]
* string: 2021-08-09T05:00:00+02:00
["total"]
* number: 0.7656
[7]
* table:
["startsAt"]
* string: 2021-08-09T06:00:00+02:00
["total"]
* number: 0.8536
[8]
* table:
["startsAt"]
* string: 2021-08-09T07:00:00+02:00
["total"]
* number: 0.8735
[9]
* table:
["startsAt"]
* string: 2021-08-09T08:00:00+02:00
["total"]
* number: 0.8917
[10]
* table:
["startsAt"]
* string: 2021-08-09T09:00:00+02:00
["total"]
* number: 0.8721
[11]
* table:
["startsAt"]
* string: 2021-08-09T10:00:00+02:00
["total"]
* number: 0.8418
[12]
* table:
["startsAt"]
* string: 2021-08-09T11:00:00+02:00
["total"]
* number: 0.8247
[13]
* table:
["startsAt"]
* string: 2021-08-09T12:00:00+02:00
["total"]
* number: 0.8182
[14]
* table:
["startsAt"]
* string: 2021-08-09T13:00:00+02:00
["total"]
* number: 0.8108
[15]
* table:
["startsAt"]
* string: 2021-08-09T14:00:00+02:00
["total"]
* number: 0.8135
[16]
* table:
["startsAt"]
* string: 2021-08-09T15:00:00+02:00
["total"]
* number: 0.8085
[17]
* table:
["startsAt"]
* string: 2021-08-09T16:00:00+02:00
["total"]
* number: 0.8252
[18]
* table:
["startsAt"]
* string: 2021-08-09T17:00:00+02:00
["total"]
* number: 0.9003
[19]
* table:
["startsAt"]
* string: 2021-08-09T18:00:00+02:00
["total"]
* number: 0.9642
[20]
* table:
["startsAt"]
* string: 2021-08-09T19:00:00+02:00
["total"]
* number: 0.9705
[21]
* table:
["startsAt"]
* string: 2021-08-09T20:00:00+02:00
["total"]
* number: 0.9249
[22]
* table:
["startsAt"]
* string: 2021-08-09T21:00:00+02:00
["total"]
* number: 0.913
[23]
* table:
["startsAt"]
* string: 2021-08-09T22:00:00+02:00
["total"]
* number: 0.887
[24]
* table:
["startsAt"]
* string: 2021-08-09T23:00:00+02:00
["total"]
* number: 0.8531
Scripts errorlog:
Tibber API 09.08.2021 22:55:24
Resident script:29: attempt to index global 'homes' (a nil value)
stack traceback:
Any hints howto proceed?
I wan't to have hourvalue 0-1 in GA 33/0/0, hourvalue 1-2 in GA 33/0/1 and so on...
BR, Odd Egil