07.05.2018, 14:03
Code:
require('json')
require('ssl.https')
now = os.date('*t')
pickhour = now.hour + 1
date = os.date('*t')
date.day = date.day
param = os.date('%d-%m-%Y', os.time(date))
res = ssl.https.request('https://www.nordpoolgroup.com/api/marketdata/page/23?currency=NOK&endDate=' .. param)
values = {}
if res then
res = json.pdecode(res)
if type(res) == 'table' then
for _, row in ipairs(res.data.Rows) do
cols = row.Columns
value = cols[ 1 ].Value:gsub(',', '.')
values[ #values + 1 ] = tonumber(value)
end
end
end
grp.write('1/1/1', values[pickhour]) -- output address
Then this works great
I had to remove the " - 1" from admins code, it led to prices from yesterday.
Mvh
Best regards, Jørn.