Any way to make OH listen for incoming web requests?

Hi,

is it possible to send http post requests to OH directly, or maybe using a third party web server and a binding in OH?
I’d like to build a rule based on incoming web requests.

Stefan

Hi, OpenHab have a REST API that enables you to do this and more. Look at
http://docs.openhab.org/configuration/restdocs.html

thx, I thought this API can only be used directly on items. like switching an existing / known lamp on and off. but I’d like to send custom commands, like setting a custom variable. as soon as the value for variable has changed, a rule will be triggerd.

Anyway, I’ll have a look :wink:

  1. Create a String/Number item, example:
Number myCustomTriggerItem
  1. Create a rule when that item changes.
rule "myCustomTriggerItem Changed"
when
	Item myCustomTriggerItem changed
then
    logInfo("myCustomTriggerItem", myCustomTriggerItem.state)
    // Do logic here based on myCustomTriggerItem.state
end
  1. Make a REST call to openHAB to update that item
POST to myCustomTriggerItem
  1. Your rule will be triggered.
  2. Do your logic
1 Like

Awesome! will give it a try. This way I should be able to use Google Home via IFTTT (sending the web request). Right? :slight_smile:

EDIT: I answer myself: yes, works like a charm :slight_smile: