Page 1 of 1

using dzvents to listen on a port

Posted: Friday 24 August 2018 15:47
by heggink
Can that be done? My Nuki locks allow me to install a hook whereby any state change is reported in a nuki json format to any ip:port I want so every time a lock is changed, it's state change is reported.
I'd like to capture these changes in dzvents instead of in my current bash script so I need some way to get dzvents to listen for json messages on a specific port on my raspberry pi (where domoticz also runs). I struggle to understand how the asynchronous http mechanism supports that...

Any help greatly appreciated.

H

Re: using dzvents to listen on a port

Posted: Friday 24 August 2018 16:01
by elmortero
Have a look at the dzvents manual, under the topic http response.

Re: using dzvents to listen on a port

Posted: Friday 24 August 2018 16:03
by heggink
that's what I tried but I fail to see how I can listen on a port without issuing a request first...

Re: using dzvents to listen on a port

Posted: Saturday 25 August 2018 8:31
by waaren
heggink wrote: Friday 24 August 2018 15:47 Can that be done? My Nuki locks allow me to install a hook whereby any state change is reported in a nuki json format to any ip:port I want so every time a lock is changed, it's state change is reported.
I'd like to capture these changes in dzvents instead of in my current bash script so I need some way to get dzvents to listen for json messages on a specific port on my raspberry pi (where domoticz also runs). I struggle to understand how the asynchronous http mechanism supports that...
If your nuki (bridge) can send something like /json.htm?type=command&param=updateuservariable&vname=NAME&vtype=TYPE&vvalue=VALUE
to domoticzIP:domoticzPORT then dzVents can be used because domoticz will then trigger an event.
As far as I understand, the current dzVents version only reacts to events triggered by domoticz.

Re: using dzvents to listen on a port

Posted: Saturday 25 August 2018 23:02
by Egregius
That won't work if it only can send a json string. You could use a small php page to decode the json.

Re: using dzvents to listen on a port

Posted: Sunday 26 August 2018 7:42
by Dnpwwo
You could create a python plugin that listens for JSON.

Under plugins/examples there is one called "HTTP Listener" which shows how to listen on an ip & port. If you set the connection's protocol to JSON rather than HTTP it will return JSON messages in dictionaries (and/or lists depending on the JSON) in the onMessage function when your Nuki sends a message.

EDIT: Just looked Nuki up, looks interesting. If you need help writing a plugin let me know.

Re: using dzvents to listen on a port

Posted: Sunday 26 August 2018 14:07
by heggink
Help? YES PLEASE. My python skills are really appalling (I'm just an old C programmer who knew when to quit ).
These nuki devices are really great. I have had them for quite a while. I did mod them to replace the batteries with a power adapter as they don't like being polled (drains the batteries).
I'll take a look at the python plugin and put some thoughts on paper.
Many thanks for the offer!