Alternative solution to switch items over HTTP without ClassicUI

Hi Forum,

with openHAB 2.5 I have some functions integrated in my BEDDI alarm clock. I make a call from the alarm clock over HTTP and switch some items over ClassicUI like this:

http://IP:PORT/classicui/CMD?Licht_OG_Schlafen=OFF
http://IP:PORT/classicui/CMD?Licht_OG_Schlafen=ON

In openHAB 3 there is no ClassiUI available anymore. With the REST API I can only make calls with CURL oder JSON over HTTP.

Do you have any ideas how I can implement few calls for switching items over HTTP?

Thanks,
Reinhard

The new HTTP Binding!

Hi,

is the HTTP Binding not for “calling” external data und bring it to openHAB?
I have read your link and I havn’t seen how to switch an openHAB-Item with this binding.

Do you have an example or hint for me?

Thanks,
Reinhard

Scroll to the bottom of the doc for commanding magic!

Hi hafniumzinc,

I think I didin’t understand the idea behind the HTTP binding. I have read the documentation and I’m not sure how to use the “command” feature to implement an external call for openHAB.

I have installed the binding and on the first step I should create a thing. And there is a mandatory field for the “Base URL”. I didn’t have an URL at this time.

I want to call from my BEDDI alarm clock an URL like this “http://OPENHABIP:OPENHABPORT/classicui/CMD?Licht_OG_Schlafen=OFF” and then openHAB (or the HTTP Binding) should update the Item “Licht_OG_Schlafen” (or trigger a rule).I need only the external trigger in openHAB (the rest is ok to script in a rule for example).

I didn’t see in the documentation or the installed binding how to solve that. :frowning:

Thanks for your help,
Reinhard

So you want to control openHAB Items over HTTP from an external device? Then yes, use the Rest API. You can use the API Explorer in the OH3 to work out what the correct URL syntax would be.

Hi,

with the REST API I can do a call like: http://OPENHABIP:OPENHABPORT/rest/items/Onkyo_Power/state and set the state to “ON” or “OFF”. That works great in the API-Explorer and. For example with CURL and “-d “OFF”” the item is switched off.

I need for my alarm clock an URL like this:
http://OPENHABIP:OPENHABPORT/rest/items/Onkyo_Power/state=ON

And this seams not possible with the REST API. I must integrate a JSON or a CURL request to do this (my BEDDI alarm clock only support call a HTTP-URL).

Is there a way to update an item or trigger an item with an “normal URL”?

Best regards,
Reinhard

Hi,

I have found a solution for me here:

and

I think it’s not the best way but I’ll test it.

I have created a “test.html” in the openHAB-HTML-Folder and can now call this HTML-File from my BEDDI alarm clock. In the HTML file a call to the REST API is integrated.

When I create to HTML files “test_on.html” and “test_off.html” I can switch my items there.

Is there a better way for integrating external calls without ClassicUI?

Thanks,
Reinhard

Edit:

I have found a little error for me in commanditem.html:

The following lines musst commented out for use with openHAB 3:

  //paramName = paramName.toLowerCase();
  //paramValue = paramValue.toLowerCase();

Found tjis usimg nginx

Hi Danny,

thanks for your solution. I have tested this and it works really good for me. I have done it like this in openHAB 3.0.1:

location ~ /statechanger/POST/([^/]+)/([^/]+) {
proxy_pass http://IP:PORT/rest/items/$1;
proxy_set_header content-type “text/plain”;
proxy_set_header accept “application/json”;
proxy_method POST;
proxy_set_body $2;
}

location ~ /statechanger/PUT/([^/]+)/([^/]+) {
proxy_pass http://IP:PORT/rest/items/$1/state;
proxy_set_header content-type “text/plain”;
proxy_set_header accept “application/json”;
proxy_method PUT;
proxy_set_body $2;
}

It only worked with the lline content-type and accept.

Thanks,
Reinhard