Nordpoll in to OH3

Is there anyone who can help me get Nordpool DK2 values into OH? I’m a little in doubt if this can be done only using ITEMS and RULES or if something else needs to be installed to get the data in. I hope there is someone who can help.

Do you want to do screen scraping or do you have access to an API ?

You must have a licensed API key to use Nordpool data, and they are quite expensive.

So I guess that the maintainer of home assistants Nordpool addon arranged some kind of license agreement.

If you use Node-RED, then there is a Node for Nordpool api including example, from Node-RED you can update the item in OH
image

1 Like

it looks like someone has been able to get values ​​out of this link, but I do not know if this is possible. Dk1 is on page 41

https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate=

I have found the following but I do not know if this is from an earlier version of OH and if this is still possible to use in OH3 Item file. and if so, how do I proceed from this.

String NP_Electricity_price_tomorrow_00_01 “Electricity price tomorrow 00-01 [% s]” {http = "<[https://www.nordpoolgroup.com/api/marketdata/page/47?currency=EUR&endDate= {}: 60000: JSONPATH ($ .data.Rows [0] .Columns [0] .Value)] "}

It is from an earlier version, yes.

No.

Assuming that the URL provides you with the expected data, install and configure the HTTP Binding on OH3, and then create an HTTP Thing. It’s easiest via the UI, but there are Things file examples for the OH3 HTTP Binding in the forum.

Following command line could be used inside an executeCommandLine or the exec binding call :

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

That would return:

"60,08"
1 Like

I have installed Exec binding in OH3 now.
Is it true that I need a Things file, Items and a Rules to get the value ?.
I have run your command in Putty and there I also get 60.08

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.