using dzvents to listen on a port

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

Moderator: leecollings

Post Reply
User avatar
heggink
Posts: 989
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

using dzvents to listen on a port

Post 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
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
elmortero
Posts: 248
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: using dzvents to listen on a port

Post by elmortero »

Have a look at the dzvents manual, under the topic http response.
User avatar
heggink
Posts: 989
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: using dzvents to listen on a port

Post by heggink »

that's what I tried but I fail to see how I can listen on a port without issuing a request first...
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: using dzvents to listen on a port

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: using dzvents to listen on a port

Post 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.
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: using dzvents to listen on a port

Post 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.
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
User avatar
heggink
Posts: 989
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: using dzvents to listen on a port

Post 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!
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest