This even lets you describe your own API/WebHooks for OpenHab. This is sometimes needed for external services or hardware that has limited ability to call http webhooks.
Supported Things
Only one thing is supported - webhook. This thing does not have any channels at first but let you add any number of it.
Discovery
Discovery is not supported
Binding Configuration
Main configuration of the created thing lies in its unique id. This is will be part of the url for a webhook endpoint processed by this thing.
Optional config is to fill Response expression / Expression . However for most cases you can leave with
resp.status=200
Channel configuration
Within a channel you configure only an expression property. Configuration is in form of a script written in Apache JEXL language. Return value of this expression will be a value that updates/commands the channel.
As for now in the expression there is only a simple object req which has only two properties:
parameters - under this property all query parameters and form-encoded post parameters are placed. So you can define in your http requests query params and extract it to channels.
body - unders this property the body of the POST requests is stored. body has two properties text and json. With this you can post a json file to you openhab and use an expression to extract an value from the json and place it into channel. See further examples.
method - POST/GET/PUT/DELETE
Context for expressions can be enriched with more than one req object in future.
Example
Following exaple of channel expression will update value of the channel whenever someone make a request to http://[youropenhab]/webhook/[thingid]/[channelid].
if (req.parameters.action[0] == "call") {
return "CALLING";
};
Suppport this project
You can support this project by sponsoring its maintainers: Piotr Bojko
I don’t think, too, that it is unique to webhook binding. But maybe the deletion of bindings appear if the binding does not meet any kind of minimum criteria or some meta data are missing?
It is not a big deal. I just wanted to bring this to the attention of the developer.
Just wondering if anyone has any idea how to get this to work with the new Unifi Protect Alarm manager. It has a webhooks option. Im not very familiar with how webhooks work or where to begin.
Advanced Settings
By default, the webhook will create an HTTP GET request each time an alarm is triggered.
For advanced cases, use the Advanced Settings:
HTTP GET allows custom headers for security tokens or other additional information.
HTTP POST delivers additional information about the alarm to your service.
Here is an example of the HTTP POST structure:
Your device supports http/post. You do not need the webhook binding.
Create an http request:
url = ‘http://61:8080/rest/items/testItem’
contentType = “text/plain”
content = “ON”
headers:
‘Accept’: ‘/’
‘Authorization’: ‘Bearer oh.rules.DhBqiiRJiotlpI2…….’
You can create an authorization token in MainUI. Click on your name in the lower left corner.
Hello first of all, thanks for this binding.
It brings my MyStorm Buttons to the possibly to use them by Openhab.
I have installed them on OH 5.0.2 and it works perfect.
After I have upgraded from 5.0.2 to 5.0.3 I have have the need, to install the binding manual once again, because it was not there anymore.
The same happens now at the major update from 5.0.3 to 5.1.0-1
What can I do, that also the WebHook binding will be updated and installed automaticly?
I assume you have installed the addon through marketplace. By intention marketplace bindings are removed if their version number does not match to your openhab version.
You could create a rule which reinstalls the binding during start up or copy the binding to your addon folder.