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

Hi!

If it is communicating through the openhab built in web server it should be available through the cloud myopenhab.org. You just need to adjust your URL-s and auth headers accordingly.

I have just checked this and you may be right. I’ve succeeded with a call through myopenhab to the webhook from the binding. You must be logged into myopenhab and the http request should contain a valid myopenhab session cookie for the call.

1 Like

I love your webhook binding.
I managed to control/get data from my Netatmo doorbell via the nginx proxy.
Thanks for sharing !

1 Like

Thank you for this binding.
Up until now I’ve been using a proxy server (written in Python) to get data from WirelessTags (Cao Gadgets) but as my Python skills are not the best, it was never really robust. Now I can get rid of it.

One difficulty was to link a webhook channel to an existing item which is not a string. The UI only offers items matching the channel type.

I got around this by temporarily changing the item to a string, linking it, then changing it back.

It would be nice if the binding offered a choice of data type for the channel. But hey, great work so far.

Will it be added to the marketplace anytime soon?

Also thank you very much for this great binding from my side!

I tested it on openHAB 3.2.0, it was working nicely.
Personally I prefer configuration files over the GUI due to the flexibility. But unfortunately I failed using a things file instead of the GUI.

gw1100.things:

Thing httplistener:HttpListener:ecowittGateway {
 Channels:
  State String : tempinf "Temperature" [
   configParameter="req.parameters.tempinf[0]"
  ]
}

The code above does not work. In the GUI the status shows “UNINITIALIZED, HANDLER_CONFIGURATION_PENDING”.

Any idea how the configuration can be applied to a .things file?

Yes, as mentioned in the thread you started on the very same topic. But you need to provide the information requested.

Thank you, my intention was not a double-post, but since @opus told me that the configuration is a binding specific question, I asked here for the binding specific answer.
My other thread was about how to add the configuration to the things file in general.

Many thanks to @hilbrand, this way seems to be the proper configuration when using .things files:

Thing httplistener:HttpListener:ecowittGateway [jsonConfig="{ \"channels\": [ { \"key\": \"tempinf\", \"kind\": \"STATE\", \"state\": \"req.parameters.tempinf[0]\" }, { \"key\": \"humidityin\", \"kind\": \"STATE\", \"state\": \"req.parameters.humidityin[0]\" } ] }"]

The status of the thing is now ONLINE, but unfortunately it still does not work.
Are there any debug capabilities (log files)?

For the moment using the GUI for configuration will be the best way. But is there a way to list the items pushed to the binding? I tried unsuccessfully with “req.body.text” (was empty).

In the repository hilbrand has also seen that that the httplistener binding was renamed to webhook and uses a different way of configuring the channels now. Are there any release plans?

Sounds great.
Would you mind sharing more information what you can control / read and how your configuration looks like?
Thank you.

Unfortunately the current release does not work for the ecowitt GW1100 (not related to my configuration posts).
I filed an issue.

will do after i‘m back home. pls be patient

Here is my thing configuration (replace the xxxxxxxxxx with your thingId)

UID: httplistener:HttpListener:xxxxxxxxxx
label: Doorbell Webhook
thingTypeUID: httplistener:HttpListener
configuration:
  jsonConfig: |-
    {
      "channels": [
        {
          "key":"user_id",
          "kind": "STATE",
          "state": "req.body.json.user_id"
        },
        {
          "key":"event_type",
          "kind": "STATE",
          "state": "req.body.json.event_type"
        },
        {
          "key":"device_id",
          "kind": "STATE",
          "state": "req.body.json.device_id"
        },
        {
          "key":"home_id",
          "kind": "STATE",
          "state": "req.body.json.home_id"
        },
        {
          "key":"home_name",
          "kind": "STATE",
          "state": "req.body.json.home_name"
        },
        {
          "key":"camera_id",
          "kind": "STATE",
          "state": "req.body.json.camera_id"
        },
        {
          "key":"event_id",
          "kind": "STATE",
          "state": "req.body.json.event_id"
        },
        {
          "key":"subevent_id",
          "kind": "STATE",
          "state": "req.body.json.subevent_id"
        },
        {
          "key":"snapshot_url",
          "kind": "STATE",
          "state": "req.body.json.snapshot_url"
        },
        {
          "key":"vignette_url",
          "kind": "STATE",
          "state": "req.body.json.vignette_url"
        },
        {
          "key":"session_id",
          "kind": "STATE",
          "state": "req.body.json.session_id"
        },
    	{
          "key":"push_type",
          "kind": "STATE",
          "state": "req.body.json.push_type"
        }
      ]
    }

Then I defined on https://dev.netatmo.com an app.
Set Redirect URI & Webhook URI to (also defined a port forwarding listen_port_webhook → openhab_external_listen_port on my router):

https://my_external_url:listen_port_webhook/httplistener/xxxxxxxxxx)

Additionally I had to configure the nginx proxy:

        location = /httplistener/xxxxxxxxxx {
                auth_basic          off;
                proxy_pass          https://internal_openhab_uri:https_internal_openhab_port/httplistener/xxxxxxxxxx;
        }

Hi. I also have an Akuvox doorstation and want to set an item when I use an RFID on my doorphone.
I configured a thing

UID: httplistener:HttpListener:903a02986d
label: HttpListener thing
thingTypeUID: httplistener:HttpListener
configuration:
  jsonConfig: |-
    {
      "channels": [
        {
          "key":"action",
          "kind": "STATE",
          "state": "req.parameters.action[0]"
        },{
          "key": "card",
          "kind": "STATE",
          "state": "req.parameters.card[0]"
        }
      ]
    }
location: Tuer

and on my doorphone I call

http://192.168.2.138/httplistener/903a02986d?card=$card_sn

(http://oh/httplistener/intercomhook?action=cardaction&card=$card_sn doesn’t work, because after “&” the code is cut on my dorrphone)

Whats wrong?

Unfurtatly it doesn’t work. In the System Log of the doorphone it shows

curl send url=http://192.168.2.138/httplistener/903a02986d?card=ACC5FB82
phone pid203,tid256,l3: [TFTPControl.cpp-452]Upload Server is empty

Awesome, thank you very much!

Is this the full thingID?
e.g. httplistener:HttpListener:LupusMotionListener

I don’t get it to work, but I assume it’s pretty simple (not for me obviously though).

My thing:

httplistener:HttpListener:LupusMotionListener

My json config:

{
  "channels": [
    {
      "key":"status",
      "kind": "STATE",
      "state": "req.parameters.status"
    }
  ]
}

And my http call from my Alarmsystem:

http://admin:xxx@nukem:8080/httplistener/httplistener:HttpListener:LupusMotionListener?status=ON

I have mapped the channel “status” to a String item, but this does not change.

Any obvious mistakes?

EDIT:
this at least creates a Sting with unexpected stuff:

curl -v 'http://nukem:8080/httplistener/LupusMotionListener?status=ON'

Result in String item:

[Ljava.lang.String;@1cc0b42

EDIT II:
I figured it out by myself - although it’s not the cleanest way.
I ended up using the TRIGGER type and created a rule to handle this trigger (although the trigger payload is the string stuff above)

Can anybody help me?

As it is http traffic accoding to your post I would do some debugging and use a network sniffer like wireshark or tshark or tcpdump and try to capture the traffic being send from the Akuvox to the openhab host to check what is being sent if it is being sent.
You also can do a manual run calling curl from an other host/PC to check what is being sent back ( ok message / error message ) from openhab.

This is my setup.
Config.Features.ACTIONURL.ValidCardEntered = http://oh.local/webhook/intercomhook?action=validcard&card=$card_sn
Config.Features.ACTIONURL.InvalidCardEntered = http://oh.local/webhook/intercomhook?action=invalidcard&card=$card_sn

I am know configuring this from the UI, because my akuvox firmware does not allowed that. I am using Upgrade → Advanced → Manual AUTOP. First you export config from the intercom, modify this and use the modified file with Manual AUTOP.

Please note, that there is really two urls, one for event you pass a card known to the intercom and one for event you pass unknown card.

I suggest that after configuring yhe listener binding you use your web browser and go to the url you expect to be called to like “http://192.168.2.138/httplistener/903a02986d?card=ACC5FB82”. You will then if it works on the OH side.

Continuing the discussion from [webhook] New, very simple binding for listening incomming http requests:

Ok. Thank you.

Unfortunately it doesn’t work.
Nothing happend on the OpenHab site.

The System Log of the doorphone shows “phone pid203,tid256,l3: [TFTPControl.cpp-452]Upload Server is empty”

Wireshark can not see any traffic when I took a Chip on the reader.

And when I use the web-browser, I got an connection error…

I have no idea, where the problem is.

Make some screenshoots from your config.