How can I use dzVents to process a webhook?

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
marcelvandorp
Posts: 3
Joined: Friday 01 February 2019 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How can I use dzVents to process a webhook?

Post by marcelvandorp »

Hi,

I use a system which is able to send a json object (using a webhook) when something happens (in my case, the message is sent when a device comes within WiFi range). I would like to receive that in Domoticz and process the information with dZvents.

Basically the system performs a HTTP POST to a specific URL and posts the content of the json to the webserver.

I wrote a small piece of code doing a webrequest and used a callback function to process the result.
That works fine with a prior request, but now I only receive results, with NO prior trigger from within Domoticz/dzVents

Is it possible to write a piece of dzVents-code which is able to receive the json in the webhook?
Processing the JSON is not the issue, getting it into dzVents is what I can't achieve.

Any help is appreciated!

Regards,

Marcel
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How can I use dzVents to process a webhook?

Post by waaren »

marcelvandorp wrote: Friday 01 February 2019 16:46 Hi,

I use a system which is able to send a json object (using a webhook) when something happens (in my case, the message is sent when a device comes within WiFi range). I would like to receive that in Domoticz and process the information with dZvents.

Basically the system performs a HTTP POST to a specific URL and posts the content of the json to the webserver.

I wrote a small piece of code doing a webrequest and used a callback function to process the result.
That works fine with a prior request, but now I only receive results, with NO prior trigger from within Domoticz/dzVents

Is it possible to write a piece of dzVents-code which is able to receive the json in the webhook?
Processing the JSON is not the issue, getting it into dzVents is what I can't achieve.

Any help is appreciated!

Regards,

Marcel
Not sure I completely understand but dzVents ( or Lua or Blocky) do not listen to webhooks directly. They are triggered by a domoticz event.
What you could do is send the webhook to ifttt or node.js / nodered and let these update a domoticz uservariable. That will cause an event and can trigger dzVents.
Last edited by waaren on Saturday 02 February 2019 0:42, edited 2 times in total.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: How can I use dzVents to process a webhook?

Post by Dnpwwo »

@marcelvandorp ,

The Python Plugin Framework sounds like the way to do what you want if you know any Pyhton. Have a look at https://www.domoticz.com/wiki/Developin ... hon_plugin and there are examples shipped with Domoticz for both HTTP clients and HTTP servers under domoticz/plugins/examples.

Plugins are callback driven which sounds like what you want. With a plugin you create devices in Domoticz that generate events that dzVents can handle
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
marcelvandorp
Posts: 3
Joined: Friday 01 February 2019 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How can I use dzVents to process a webhook?

Post by marcelvandorp »

@dnpwwo,

What you describe and what you refer to sounds promising! I did find the example listener code (has a familiar author :) and I will dig into it to see if I can make it do what I want.

I have to make myself familiar with the plugin system first, but when I have something usable, I'll share it here.

Thanks,

Marcel
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest