FYI : Faster socket.send(...
Posted: 01 Jul 2020 16:26
Having recently swapped all my 433.92 inwall's to fibaros I am doing quite a bit of work on updating / cleaning up / speeding up my home auto setup.
I'll share some of the things I am doing since I am using z-way-server as the interface to my z-wave mesh.
Here's the first one:
I used socket.send(.... to send UDP datagrams to a nodejs backend. This works quite nicely to get things from my zwave into my OpenHAB setup. One of the issues I had is I found that sock.send(... (in z-way-server's JS engine) tends to be a bit slow... I am unsure where the bottleneck is, but there would be an about 0.5 to 1 second delay between when I logged on z-way-server via console.log and when the datagram would hit my nodejs backend.
I found a solution that is working quite nicely, use system(... to invoke socat and send the datagram that way.
Yeah, we are talking about 0.5 seconds here... But for anything motion sensor based, it makes the experience quite a bit nicer... Here is a dump of the command I am invoking instead of socket.send now... Beware, add printf to your .syscommands file or else z-way-server will not execute the command:
If anyone sees any issues using this instead of socket.send let me know!
I'll share some of the things I am doing since I am using z-way-server as the interface to my z-wave mesh.
Here's the first one:
I used socket.send(.... to send UDP datagrams to a nodejs backend. This works quite nicely to get things from my zwave into my OpenHAB setup. One of the issues I had is I found that sock.send(... (in z-way-server's JS engine) tends to be a bit slow... I am unsure where the bottleneck is, but there would be an about 0.5 to 1 second delay between when I logged on z-way-server via console.log and when the datagram would hit my nodejs backend.
I found a solution that is working quite nicely, use system(... to invoke socat and send the datagram that way.
Yeah, we are talking about 0.5 seconds here... But for anything motion sensor based, it makes the experience quite a bit nicer... Here is a dump of the command I am invoking instead of socket.send now... Beware, add printf to your .syscommands file or else z-way-server will not execute the command:
Code: Select all
system("printf '"+JSON.stringify(OBJECT TO SEND TO UDP BACKEND)+"' | socat -t 0 - UDP:TARGETIP:TARGETPORT");