[SOLVED] myHomeControl Garmin > HTML send command to item in Openhab

How to send from browser command to switch
e.g. “http://192.168.1.111:8080//items/Switch=ON” or “http://192.168.1.111:8080//items/Switch=OFF
In application myHomeControl Garmin i have to use http action url

Use the http binding or action.

can you give examples?

Install http binding.
Create a myitems.items file and put inside:

Switch MyItem1 "My Label" { http=">[ON:POST:http://xxxxxxxxxxx] >[OFF:POST:http://xxxxxxxxxxx]" }

xxxxxxxxxxxx = your string

Also see this docu.

Not this,
I need in Web browser (google chrome) put url
eg http://openhabip:8080/myitem1/ON…

Ohhh. The other direction. Sorry! :slight_smile:

EDIT: Install “REST Documentation” in “User Interfaces” via PaperUI.

I found REST API, but this give me only status, do have someone experience?

1 Like

@beginer

You can use this in Rest API: POST /items/{itemname}

What will be the path for ON, and how it will be for OFF
(JSON** path?)

@beginer

This it not possible. You need a “Curl command”.

Or as a quick solution, you need to install the classicUI. Maybe (I’m not sure!) you need also a .sitemap file. See here!
.

Then the following “commands” should run:

ON:
http://IP-of-Openhab:8080/classicui/CMD?MyItem1=ON
OFF:
http://IP-of-Openhab:8080/classicui/CMD?MyItem1=OFF

1 Like

It’s worth noting that the ClassicUI approach is not and has never been an officially supported way to command Items. It is completely possible that at some point ClassicUI and/or this work around will cease working at any point in the future.

Thanks for the hint. :slight_smile:

Please compare this: https://github.com/openhab/openhab1-addons/wiki/Samples-Tricks#use-url-to-manipulate-items

Is there a better (more elegant) way to reach this? What would you recommend?

Here is the detailed description of MyHomeControl. Link(click on … More).

There was a lot of stuff in the OH 1.x wiki that the developers never considered “official”. Kai and others have stated multiple times over the years that the ClassicUI work around is not officially supported. And come OH 3 I would not be surprised if ClassicUI support goes away (no, I’ve not seen any indication either way on this, it’s just a hunch).

Not really. The REST API is the official way to command Items over http. There is no officially supported way I know of to command or update an Item using an HTTP GET command.

I suspect a binding or a work around like I implemented in OAuth2 using just OH Rules and myopenhab.org. If you look at the HTML file, you will find JavaScript that parses out the arguments from the URL and issues an HTTP POST to command an Item using JavaScript. It would not take much to have the Item name be passed as an argument instead of hard coding it. Then you just drop the html file into %OH_CONF%/html folder.

1 Like