Skip to content

Generic class to map Z-Wave CommandClasses to Homey capabilities

Notifications You must be signed in to change notification settings

mnederlof/node-homey-zwavedriver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZwaveDriver

Generic class to map Z-Wave CommandClasses to Homey capabilities, for faster Z-Wave App development.

Z-Wave docs

Please also read the Homey Z-Wave docs here: https://developers.athom.com/library/zwave/

Installation

cd /path/to/com.your.homeyapp/
git submodule add [email protected]:athombv/node-homey-zwavedriver.git node_modules/homey-zwavedriver

Example

File: /drivers/mydriver/driver.js

'use strict';

const ZwaveDriver = require('homey-zwavedriver');

module.exports = new ZwaveDriver('mydriver', {
	debug: false, // set to true to view all incoming events
	capabilities: {
		'onoff': {
			'command_class'				: 'COMMAND_CLASS_SWITCH_BINARY',
			'command_get'				: 'SWITCH_BINARY_GET',
			'command_set'				: 'SWITCH_BINARY_SET',
			'command_set_parser'		: function( value ){
				return {
					'Switch Value': value
				}
			},
			'command_report'			: 'SWITCH_BINARY_REPORT',
			'command_report_parser'		: function( report ){
				return report['Value'] === 'on/enable';
			},
			'getOnWakeUp': true, // if set to true and device is battery powered this capability will perform a GET everytime the device wakes up
		},
		'measure_power': {
			'command_class'				: 'COMMAND_CLASS_SENSOR_MULTILEVEL',
			'command_get'				: 'SENSOR_MULTILEVEL_GET',
			'command_report'			: 'SENSOR_MULTILEVEL_REPORT',
			'command_report_parser'		: function( report ){
				return report['Sensor Value (Parsed)'];
			},
			'optional': true // if device variably advertises a command class (e.g. cc battery when dc-powered) set this variable to true to prevent crashes
		}
	},
	beforeInit: (token, callback) => {
	    // this method is called right before the initialization of a device (before it gets marked as available)
	},
	settings: {
		'always_on': {
			'index': 1,
			'size': 1
		},
		'led_ring_color_on': {
			'index': 61,
			'size': 1,
			
			// define a custom parser method (optional)
			'parser': function( input ) {
				return new Buffer([ parseInt(input) ]);
			}
		},
		'led_ring_color_off': {
			'index': 62,
			'size': 1
		},
		'sensitivity': {
			'index': 63,
			'size': 1,
			
			// set signed to false to let (0, 255) scale to (0x00, 0xFF)
			// otherwise the domain is (-128, 127) for size=1
			'signed': false
		}
	}
});

About

Generic class to map Z-Wave CommandClasses to Homey capabilities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%