Nordpoll in to OH3

This rule fetch the data from Nordpool

Im trying to use the method, I can see it fetched data just fine but im having trouble changing dot to comma.

Thanks Mads

Although I stated earlier to use the exec binding it may be easier to use executeComandLine.
You need to have e.g. an item that can be used to display the current value.
Besides that just a rule is required. A DSL rule could look like:

rule "Get the price"
when
        Time cron "0 0 * * * ?" //run every hour
then
        var Number tmp = executeCommandLine( Duration.ofSeconds(5), "/path/to/scripts.sh" )
        Price.postUpdate( tmp )
end

This would use a cron entry which runs triggers the execution every hour.
Path to script needs to be replace with the correct path of the script containing the wget/curl command etc.

Using the code example that I provided you could use sed to replace dot with comma ( the example below uses two sed commands as a comma is already provided; first one changes , to .; second one . to , ) :

wget --quiet -O - 'https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=' | jq '.data.Rows[0].Columns[0].Value' | sed -e 's/,/./' | sed -e 's/\./,/'

i have tried the following:

rule “Get the price”
when
Item Renew_price changed
then
var Number tmp = executeCommandLine( Duration.ofSeconds(5), “wget --quiet -O - ‘https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=’ | jq ‘.data.Rows[0].Columns[0].Value’” )
Electricity_price.postUpdate( tmp )
end

Number Electricity_price “Electricity_price [%.2f]” (GF_Office)
Switch Renew_price “Renew_price” (GF_Office)

But i get an error in log view:
Failed to execute commandLine ‘[wget --quiet -O - ‘https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=’ | jq ‘.data.Rows[0].Columns[0].Value’]’

You can use a ( single ) linux command in executeCommandLine but arguments have to be separated into single arguments of executeCommandLine. They have to be separated by commas.
executeCommandLine does not support the pipe ( | ) to be part of the command that is to be used.
This is why you need to create a script in the linux environment which contains all of your commands ( the complete piped command wget …jq …; it even would be possible to add more lines there ).
The use just that script as argument in executeCommandLine as written in my earlier post.

The script content will look like:

#!/bin/sh
wget --quiet -O - 'https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=' | jq '.data.Rows[0].Columns[0].Value'

Make it readable and executable:

chmod ugo+rx /path/to/your/script

As a slight aside, the URL https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate= does not produce valid JSON so the earlier mentioned method of using the HTTP binding together with the JSONPATH transformation would likely not work.

Looks like @Wolfgang_S method is the way to go here.

I take that back. The following works fine:

UID: http:url:nordpool
label: HTTP URL Thing
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=
  delay: 0
  stateMethod: GET
  refresh: 60
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: value
    channelTypeUID: http:string
    label: Value
    description: ""
    configuration:
      stateTransformation: JSONPATH:$.data.Rows[0].Columns[0].Value

To get a usable Number type Item without messing about with files, you can use the Math Transformation Service provided by the SmartHomeJ repository, and then add a DIVIDE profile to the link between the Thing Channel and the Item.

UID: http:url:nordpool
label: HTTP URL Thing
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=
  delay: 0
  stateMethod: GET
  refresh: 60
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: value
    channelTypeUID: http:string
    label: Value
    description: null
    configuration:
      stateTransformation: JSONPATH:$.data.Rows[0].Columns[0].Value
  - id: value2
    channelTypeUID: http:number
    label: Value2
    description: null
    configuration:
      stateTransformation: JSONPATH:$.data.Rows[0].Columns[0].Value

3 Likes

How do i find on what page SE3 is on?

i think this is it.
https://www.nordpoolgroup.com/api/marketdata/page/29?currency=EUR&endDate=

1 Like

This works well.
I now use the time prices to decide if i should start equipment e.g. poolheater.

Has NordPool changed their setup on the page I’m pulling data from?. I no longer get data from the site into OH3. it worked fine until now but not anymore.

the curl example still seems to work.

Here is an alternative method: GitHub - kipe/nordpool: Python library for fetching Nord Pool spot prices.

does this commando still work? I get no value in Putty when I try it.

which one ? Just tried following example and it seems to work
script contains:

#!/bin/sh
wget --quiet -O - 'https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=' | jq '.data.Rows[0].Columns[0].Value'

Executed on command line:

sh /tmp/a.sh

then returns:

"103,37"
1 Like

it seems that it was a mistake in how I had set up static ip on my raspberry that was to blame for the problems. the commands and prices are now up and running again, thanks for the feedback.

Hi all, I managed to set up the HTTP binding to poll the values into OpenHAB, however I have a bit difficulty to convert the number with “,” as decimal separator to float numbers. Any suggestion what to do? Many thanks

Below is my things:

Thing http:url:NordPool "NordPool EL Price" [
	baseURL="https://www.nordpoolgroup.com/api/marketdata/page/41?currency=DKK",
	refresh=1000] {
		Channels:
			Type string : Price "Price" [stateTransformation="JSONPATH:$.data.Rows[0].Columns[1].Value" ]
}

And item:

Number    NordPoolELPricePrice    "Price"           (gNordPool)    {channel="http:url:NordPool:Price"[profile="transform:JS", function="nordPoolPrice.js"]}

As you can see I tried to use transform profile which doesn’t seem to take any effect.

hi, I know it’s a bit of an old thread, but how do you transfer the data to openhab, I’ve tried using the function node that was created as an example here node-red-contrib-nordpool-api-plus (node) - Node-RED
and then from that directly in to a number item, which also results in transferring the entire series of data to the same item. do you do it the same way or do use another approach?

Anders

Hi Anders, I was struggling to get openHAB or Influx to show a graph with data in the future, so I ended up with just created a page with web link to elspotpris.dk.
Only number I needed in openHAB is the Spot price including tax and vat. Big Timer change between low and high tax depending on the hour, each hour request to Nordpool, this also set time now to global.set, chart data add the tax and vat, a change switch filter out the spot price now and update the item from openHAB


Nordpool to openHAB.json (14.6 KB)

1 Like

thank you, it works well :slight_smile:

Here’s a solution which fetches the prices from Entso-E Transparency platform