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

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.

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