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 ( - 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)

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

So a command to load into your switch might be —

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

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