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

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.

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

grafik

Hope thats all

Any idea?

Just to be sure? What port do your openhab use?

8080 I think

Assuming 192.168.2.138 is the IP of your openhab and you using your openhab through
http://192.168.2.138:8080 have you tried with appropriate port?

http://192.168.2.138:8080/httplistener/903a02986d?card=ACC5FB82

Now it works. Thank you.
I’m sure that I tried this before…

1 Like

Hi Piotr, I’m having trouble working out how to access form-encoded post parameters.

The POST (from Emby) has a single parameter called “data” containing json. Example from webhook.site:

But I can’t work out how to get the value of “data” into a channel. I’ve tried these with no luck:

{
  "channels": [
    {
      "key": "Event",
      "kind": "STATE",
      "state": "req.parameters.data"
    }
  ]
}
{
  "channels": [
    {
      "key": "Event",
      "kind": "STATE",
      "state": "req.parameters.data[0]"
    }
  ]
}

Any idea where I’m going wrong?

req.parameters is for query url parameters, not the POST body payload.

try to tinker around req.body.text or req.body.json. You have a POST request with form encoded payload body and this is not supported well now

Thanks Piotr, yes I came to the same conclusion. I couldn’t find any combination that works with (multipart) form-data, so I’ve gone down the node red road instead.

The binding also works for me for a Foscam VD1 doorbell under openHAB 3.3.

Can you also make a 3.3 snapshot or even better an official binding?

1 Like

I use the bindig to integrate my Garmin watches to OH.
I’m using the APICall App on the Garmin, to send the get calls to the httplistener.
It communicates via SSL trough myopenhab.org and it works like a charm.
I’d also like to see the httplistener as an offical binding.

I’d love to learn more about this!