Maybe this is not possible, but it is worth a question.
Nordpool got this webpage that publish tomorrows energy prices. This information will be important when the energy prices will be dynamic and follow these prices in our country from 2019. A combination of this price information and maybe treshold values will be good to have when trying to create a load control for controlling the energy consumption.
My problem is that this information has to be converted to KNX. I can see that it is possible to get this information by downloading an Excel sheet.
Is it possible to create a script that download this Excel sheet everyday?
And if so, this information should be sent by KNX once an hour as it is in the table. For example, 12:00 the price for 12-13 is sent, 13:00 the price for 13-14 is sent.
Is all this possible or it just a dream from my side?
You will get a table with 30 items as the result (24 hour value + min/max/etc).
You can change the location by modifying cols table index (1 = Oslo, 2 = Kr.sand, 3 = Bergen, 4 = Tr.heim, 5 = Molde, 6 = Tromsø).
Code:
require('json')
require('ssl.https')
res = ssl.https.request('https://www.nordpoolgroup.com/api/marketdata/page/23?currency=NOK')
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
res = ssl.https.request('https://www.nordpoolgroup.com/api/marketdata/page/23?currency=NOK')
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
log(values[pickhour])
This seems to work, run it as a scheduled script 1 minute over every hour.
But with the current link in there, it looks like it's getting prices for the next day`?
(05.05.2018, 18:35)Jørn Wrote: This seems to work, run it as a scheduled script 1 minute over every hour.
But with the current link in there, it looks like it's getting prices for the next day`?
Thanks, will try that out.
Yes, that is correct and that is the challenge. The time price has to be either stored or something and I want the LM5 to write the address for the actual hour.
For example, we collect tomorrow prices today and tomorrow the LM5 has to write "201,25" 12:00 to a group address at the KNX bus.
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
Allright, cleaned that up and added some other (i think) useful functions (:
Also put all configurable parameters easily available at the top of the script.
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[ city ].Value:gsub(',', '.')
values[ #values + 1 ] = tonumber(value)
end
end
end
Can anyone see what is wrong? Think I tried to fix it, but I messed around with so many different versions of the scripts that I lost track.
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/Market-data1/Dayahead/Area-Prices/NO/Hourly/?dd=NO5&view=table' .. 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
"Automatic extraction of data from this website and/or use for commercial purposes is strictly prohibited under Nord Pool’s terms & conditions. For more information regarding data usage, contact pds@nordpoolgroup.com."
03.03.2019, 19:15 (This post was last modified: 03.03.2019, 19:15 by Mr.D.)
Hi,
I haven't tried any of the scripts mentioned in these posts, but I can see that there might be some "legal" issues causing the script not to work.
Have you found a workaround? As mentioned in the post this is becoming more and more important here in Norway.
For once this would become very handy for scheduling charing of my car, also for trying to avoid peaks when it comes to heating cables etc.