Rest-API setup in openhab

I have found out, that I can get some data from some sites with Rest-API. (smart-me.com and eloverblik.dk)
But I have never really been into programming in Openhab, so I have no clue where to start.
I have installed the HTTP-bindning. but I don’t know how to configure it.
Do I have to use rules? transformations? Do I have to put some configuration-files in the Openhab-conf folder, or a subfolder on my pi4. etc. etc.

Can any link to a “step by step” tutorial on, how to access APIs on the web, through openhab?
it could be a text or video tutorial. so I can get startet.

I’m not seeking direct help for my config, at this moment.

Peter

A REST API just means that you interact with the service using standard HTTP calls.

In OH, making standard HTTP calls can be done in one of three different ways:

  1. using the HTTP binding
  2. using the sendHttpXRequest actions
  3. using Exec/executeCommandLine to use the command line utility curl

The hard part though is going to knowing what HTTP calls to make. Does it require authentication? What formats? Are there special headers? These are the sorts of questions you need to answer and you will not find those answers here. Those are specified by the provider of the REST API.

One you know what HTTP calls to make and the requirements for those calls, it’s just a matter of configuring OH to make those calls in those ways. And when you have the answers to the above, the configuration will likely be pretty obvious. But if not, we can answer specific questions.

For generic information on how to configure the HTTP binding, see Adding Things - Advanced | openHAB. The HTTP binding gets configured very similarly to the MQTT binding. But, again, the challenge isn’t how to configure, the challenge is what to configure and we can’t tell you that.

If the concepts of GET, PUT, POST, headers and such don’t make much sense to you, look up some general HTTP and/or REST API tutorials.

Thank you.

I knew that I had a working link, but I was in doubt how to configure it.
The link for Things - advanced, did the trick.

Peter

I’m truly amazed on the time and effort, you are bringing to this forum. - Thank you

Hi Jorgensen,

I’ve been struggling for 3 days with this (after 3+ years with openhab) and i cannot wrap my head around it…

Can you please post your solution. I would like to take data from exactly eloverblik.dk.

Using the HTTP binding I managed to get a token but using the token string from the item receiving it, to the headers for the other calls eludes me. I ended up using the JINJA transform for the body as here (HTTP binding send JSON body in PUT request (restful api)) but that just gives me 400 Bad request, which according to the docs for the API means I am not authorized. Yet the token works from python… This is really frustrating as it took me 10 mins to get the whole thing going in python and the supposedly trivial part of porting to openhab has been a nightmare…

Thanks for the help!

I did try using eloverblik.dk in the beginning, but i couldnt use it either.
So I bought the smart-me module.

Peter

I think i got somewhere with this :slight_smile: See here: Bringing electricity information from eloverblik.dk and energidataservice.dk into Openhab