Use REST GET as a trigger

Hi, I have a simple wifi button (which I got at work for testing purposes), which can send a GET-request to any URL when pressed (https://www.texxmo-shop.de/epages/82740787.sf/en_US/?ViewObjectPath=%2FShops%2F82740787 - see Button “GET”).

My question is, can I set up a rule, which gets triggered when the button requests any REST GET information from openHAB?

Would the ClassicUI http service work for you?

(You don’t need to configure anything, just have it loaded, then use the unique name of the Item you want to change)

https://www.openhab.org/docs/configuration/ui/classic/

And create a command in the switch like the one shown here ?

So a command to load into your switch might be —

http://192.168.xxx.xxx:8080/classicui/CMD?My_Switch=ON

Then use a DSL rule or NodeRed flow to turn the OH switch off again.

The only problem with Stuart’s approach is that ClassicUI is basically end of life and that particular HTTP GET call was never really officially supported. Consequently this approach is not guaranteed to work forever. And it kind of sucks to install a whole UI just to allow this one call.

Luckily, back when I was trying to figure out how to do some OAuth stuff, I figured out how to do this using just an http file in $OH_CONF/html.

See OAuth2 using just OH Rules and myopenhab.org.

You will only need to pay attention to the HTML File section. This includes some JavaScript to parse the arguments from the URL and then uses XMLHttpRequest to issue the POST to the OH REST API.

Thanks Rich, I didn’t know that.

It might upset Doorbird owners.

(Not me)

I did provide an alternative. :wink:

1 Like