Socket
Socket
Sign inDemoInstall

zwaveip

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

zwaveip

A Z-Wave IP implementation for Node.js


Version published
Maintainers
1
0

Weekly downloads

Readme

Source

zwaveip-node

A Z-Wave IP implementation for Node.js. Unofficial library, not supported by Sigma Designs.

This library enables node.js application to communicate with Z-Wave devices via a Z/IP (Z-Wave IP) Gateway.

To install the library

npm install zwaveip

To import the library

let ZWaveIP = require('zwaveip');

To convert the Z-Wave network's PSK (Pre-Shared Key) password from a hex string to the required binary representation

let convertHexStringToBinaryPsk = function(hexString) {
    let result = Buffer.alloc(hexString.length / 2);

    for (let i = 0; i < hexString.length; i += 2) {
        result[i / 2] = parseInt("0x" + hexString.substr(i, 2), 16);
    }

    return result;
}

To connect to a Z-Wave device

let deviceConnection = ZWaveIP.connectToZWaveDevice(ipAddress, pskIdentity, pskPassword);

To send a message to the connected Z-Wave device (example)

deviceConnection.sendMessage(ZWaveIP.CommandClass.SwitchBinary, ZWaveIP.SwitchBinaryCommand.Set, [0xFF]);

To send a message and then wait for an acknowledgment using Promises (example)

deviceConnection.sendMessage(ZWaveIP.CommandClass.SwitchBinary, ZWaveIP.SwitchBinaryCommand.Set, [0xFF])
.then(
    function() {
        console.log('Message acknowledged.');
    },
    function(err) {
        console.log('Message failure: ' + JSON.stringify(err));
    }
);

To request device status from the connected Z-Wave device (example)

deviceConnection.sendMessageAndWaitForResponse(ZWaveIP.CommandClass.SwitchBinary, ZWaveIP.SwitchBinaryCommand.Get, [], ZWaveIP.SwitchBinaryCommand.Report)
.then(
    function(response) {
        let powerStateAsByte = response.data[0];
        let powerStateAsBoolean = (powerStateAsByte != 0);
        console.log("powerState: " + powerStateAsBoolean + " (" + powerStateAsByte + ")");
    },
    function(err) {
        console.log('Message failure: ' + JSON.stringify(err));
    }
);

To close a Z-Wave device connection

deviceConnection.close(callback);

To prevent a Z-Wave device connection from blocking the Node.JS process from exiting (identical to udp socket functionality)

deviceConnection.unref();

To discover the virtual IPv4 address of a Z-Wave Gateway Controller on your local network

ZWaveIP.findGatewayControllerIpv4Address()
.then(
    function(ipv4Address) {
        console.log(" FOUND: Z/IP Gateway controller IPv4 address is: " + ipv4Address + "\n");
    },
    function(err) {
        console.log('Could not discover the Z-Wave Gateway Controller's virtual IPv4 address: ' + JSON.stringify(err));
    }
);

To discover all Z-Wave devices in your Z-Wave network

ZWaveIP.requestNodeListFromGatewayController(gatewayIpAddress, pskIdentity, pskPassword)
.then(
    function(nodeList) {
        let ipAddress = nodeList[index].ipv4Address === null ? nodeList[index].ipv6Address : nodeList[index].ipv4Address;
        console.log('Z-Wave Node # ' + nodeList[index].nodeId + ' (' + ipAddress + ')');
    },
    function(err) {
        console.log('Could not request node lsit from the specified Z-Wave Gateway Controller: ' + JSON.stringify(err));
    }
);

Documentation on Z-Wave command classes and Z-Wave commands
For full documentation, see: http://zwavepublic.com/downloads
For JavaScript enumerations, see the 'index.js' within this package's folder

Keywords

FAQs

Last updated on 06 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc