[webhook] New, very simple binding for listening incomming http requests

Which link or ip do I have to call for the actions to happen?
for Heat, print, finish and off

Try this

ok, iā€™m just too stupid for that :confused:
Iā€™m new to openhab.

Basically within this webhook like binding you describe what should happen (whith some channels and items in openhab) when someone (other system ) make a http request to a specific url in openhab.

Assuming you have an openhab under address http://myopenhab or http://192.168.1.146 (ip of your openhab), and you have created a thing withing webhook binding exactly as you have shown - then your url to call is:

http://myopenhab/httplistener/PrusaPrinterā€¦
or http://192.168.1.146/httplistener/PrusaPrinterā€¦

if you enter this addess in webbrowser - this binding will be notified and process your request. How to process it and update your item - is described in those little snippets of code you pasted (like: finish channel will be upated using snipper ā€œreturn req.parameters.finish[0]ā€ which means that should be updated with value of url paremeter ā€œfinishā€)

Example

following

curl http://myopenhab/httplistener/PrusaPrinter?heat=2&print=1&finish=3&off=yup

should update channel heat with value ā€œ2ā€, channel print with value ā€œ1ā€, channel finish with value 3 and off with value ā€œyupā€.

I hope this clarifies a little more for you :slight_smile:

OK. Yes, that makes sense^^

Now I just need to know how to set it up in openhab.

the printer has these 4 functions what it should do
#1 Heat ā†’ LED Red
#2 Print ā†’ LED White
#3 Finish ā†’ LED Green
#4 Off ā†’ Plug Off

that means these 4 functions have to be called individually and linked to the objects?
http://192.168.192.7:8080/PrusaPrinter?Heat=
http://192.168.192.7:8080/PrusaPrinter?Print=
Http://192.168.192.7:8080/PrusaPrinter?Finish=
Http://192.168.192.7:8080/PrusaPrinter?Off=

As first step I would not do any rules, but rather add items to created channels and check if those items change values if you make requests to urlsā€¦ If it work - configure webhoooks on your printer to use them when the printer changes its state. And then - check again if it is registered on your items in openhab.

1 Like

yay its work =)

@Piotr_Bojko Is this still active ? Has the http listener binding made it to the official Openhab release 3.4 ?

No, I didnā€™t make it. I had some health issues I didnā€™t consider to influence my spare time :frowning:

I will try to rethink how to deliver it to openhab base code and get back here.

Piotr, sorry to hear that. Hope youā€™re well and healthy again. There are priorities in life and an Openhab binding is indeed not one of them

Iā€™ve rebased the code against openhab 4.0.0-SNAPSHOT.

I must do at least a simple docs to be part of the Add-ons | openHAB and read about code requirements for pull requests to openhab basecode.

You can also add it to the third-party marketplace by posting in the forum. That would enable you to do more testing before adding it to an official release.

Hi Piotr

I am searching a way to send information via https to OpenHAB.
Is this also supported in your ā€œbindingā€?

Thank you.
BR Sebastian

This binding is embedded in openhab and uses its tomcat/jetty to deploy its servlet. If your openhab instance is accessible via https then the binding also is accessible.

1 Like

Hello @Piotr_Bojko,

is there or will there be a version for OH 4?

Greetings Holger

Binding works for me on OH4

Hi folks, for sure I will release the binding to the 3rd party marketplace. Previously I thought that I can manage to push it to the official bindings repository, but this is possible beyond my commitment.

As for now I struggle with my financial condition and other family things so this binding must wait a month or two for better times.

Confirming that this binding works under OHv4 means lots for me - thank you :slight_smile:

4 Likes

Hi,

since Iā€™ve updated to OH4 my door bell doesnā€™t bell.
I do not get any warnings or errors, so something seems to be wrong.

This is my thing:

Thing httplistener:HttpListener:klingel "Klingel Webhook" [
    jsonConfig="{ channels : [{
      'key': 'action',
      'kind': 'STATE',
      'state': 'req.parameters.action[0]'
    }] }"
]

and this is my item:

Switch  Klingel {channel="httplistener:HttpListener:klingel:action" }

Iā€™ve also added a rule which should play the doorbell.mp3. The rule is working properly when I trigger it manually.

When I am now using Postman and send a GET Request to:
http://[myOpenhab]/httplistener/klingel?action=klingel

ā€¦nothing happens.

Did I forget anything after upgrading to OH4?

@Piotr_Bojko: I am a software developer. Maybe I can help you bringing this binding to Marketplace. I think it is very useful but I am not so deeply inside the OH architecture.

1 Like

Welcome to the openHAB community!
I also had problems after migration to oh4. I did a couple of actions but donā€™t know which of them are responsible that it is working now:

  • enable inkompatible add-ons in MainUIā€™s settings (Add-on Management)
  • Fix Permissions (there is a menu item for this in openhabian-config)
  • clean cache
  • added a thing through openhabā€™s restAPI

However, I am using triggers of this binding. Maybe also worth a try.
In any case after I migrated to v4 I was not able to see the binding anymore during adding a new thing in the ā€œchoose bindingā€ dialog.

Can you check in karaf if the bundle is active?
Are you on JDK v17 and bullseye?