Page 1 of 1

How can I use dzVents to process a webhook?

Posted: Friday 01 February 2019 16:46
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

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

Posted: Friday 01 February 2019 17:19
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.

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

Posted: Saturday 02 February 2019 0:07
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

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

Posted: Saturday 02 February 2019 16:04
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