ZwaveDevice

Extends Homey.Device

Device settings used by system capabilities:

  • invertWindowCoveringsDirection type checkbox, Used by several windowcoverings capabilities, if true it will invert the up/down direction
  • invertWindowCoveringsTiltDirection type checkbox, Used by several windowcoverings capabilities, if true it will invert the tilt direction

Instance Properties

thermostatSetpointType

thermostatSetpointType: string

The 'Setpoint Type' used for the target_temperature capability.

Type

  • string

Instance Methods

configurationGet

(async) configurationGet(options): any

Method that retrieves the value of a configuration parameter from the node.

Parameters

Name Type Description
options
object
index
number

Parameter index

}

Returns

any

configurationSet

(async) configurationSet(options, value): Promise.<any>

Wrapper for CONFIGURATION_SET. Provide options.id and/or options.index and options.size. By default options.useSettingParser is true, then the value will first be parsed by the registered setting parser or the system parser before sending. It will only be able to use the registered setting parser if options.id is provided.

Parameters

Name Type Description
options
object
index
number
size
number
id
number
signed
boolean <optional>
useSettingParser
boolean <optional>
default:true
}
value
any

Returns

Promise.<any>

disableDebug

disableDebug()

Disable debugging to the console

enableDebug

enableDebug()

Enable debug logging on this device. Logs all incoming reports.

executeCapabilitySetCommand

(async) executeCapabilitySetCommand(capabilityId, commandClassId, value, opts): Promise.<any>

This method executes the capability set command for a given capability/commandClass combination. The capability and commandClass must be registered before this method is called.

Parameters

Name Type Description
capabilityId
string
commandClassId
string
value
number | boolean | string

the capability value to set (e.g 0 - 1 for dim)

opts
object

capability options object

Returns

Promise.<any>

getCommandClass

getCommandClass(commandClassId, opts): Error|boolean|any

Method that gets a CommandClass object by commandClassId. Optionally, it can get the object on a multichannel node if the multiChannelNodeId is provided.

Parameters

Name Type Description
commandClassId
string
opts
object
multiChannelNodeId
number

Provide this id if the command class should be located on a mc node.

}

Returns

Error | boolean | any

getManifestSetting

getManifestSetting(id): object|Error

Get a specific setting object from the manifest

Parameters

Name Type Description
id
string

Setting id to retrieve

Returns

object | Error

getManifestSettings

getManifestSettings(): Array.<any>

Method that flattens possibly nested settings and returns a flat settings array.

Returns

Array.<any>

getMultiChannelNodeIdsByDeviceClassGeneric

getMultiChannelNodeIdsByDeviceClassGeneric(deviceClassGeneric): Array.<number>

Method that gets all multi channel node ids that have a specific deviceClassGeneric.

Parameters

Name Type Description
deviceClassGeneric
string

Returns

Array.<number>

hasCommandClass

hasCommandClass(commandClassId, opts): boolean

Method that will check if the node has the provided command class

Parameters

Name Type Description
commandClassId
string

For example: SWITCH_BINARY

opts
object
multiChannelNodeId
number

Multi channel node id to check for command class

}

Returns

boolean

meterReset

(async) meterReset(multiChannelNodeId, options): Promise.<any>

Method that resets the accumulated power meter value on the node. It tries to find the root node of the device and then looks for the COMMAND_CLASS_METER. In case of a CommandClass version >= 6, the options object will be provided to set which meter needs to be reset and to what value. By default it resets the kWh meter to 0.

Parameters

Name Type Description
multiChannelNodeId

define the multi channel node id in case the COMMAND_CLASS_METER is on a multi channel node.

options

options given to the METER_RESET command, Only used when version >= 6

Returns

Promise.<any>

onDeleted

onDeleted()

Remove all listeners and timeouts from node

onMeshInit

(abstract) onMeshInit()

deprecated since v1.0.0 - Legacy from homey-meshdriver, use onNodeInit instead. This method can be overridden. It will be called when the ZwaveDevice instance is ready and did initialize a Homey.ZwaveNode.

onNodeInit

(abstract) onNodeInit(node)

This method can be overridden. It will be called when the ZwaveDevice instance is ready and did initialize a Homey.ZwaveNode.

Parameters

Name Type Description
node
Homey.ZwaveNode

Example

const { ZwaveDevice } = require('homey-zwavedriver');

class MyZwaveDevice extends ZwaveDevice {
  onNodeInit({ node }) {

    // `node` is also available as `this.node` on the ZwaveDevice instance after
    // `onNodeInit` has been invoked.
    await node.CommandClass.COMMAND_CLASS_BASIC.BASIC_SET({ "Value": true });
  }
}

onSettings

(async) onSettings(oldSettings, newSettings, changedKeysArr): Promise.<string>

Method that handles changing settings for Z-Wave devices. It iterates over the changed settings and executes a CONFIGURATION_SET in sync. If all succeed, it will resolve, if one or more fail it will reject with an error of concatenated error messages (to see which settings failed if more than one).

Parameters

Name Type Description
oldSettings
newSettings
changedKeysArr

Returns

Promise.<string>

printNode

printNode()

Print the current Node information with Command Classes and their versions

printNodeSummary

printNodeSummary()

Prints oneliner node summary, e.g. firmware information and device identifiers.

refreshCapabilityValue

(async) refreshCapabilityValue(capabilityId, commandClassId): Promise.<any>

Method that refreshes the capability value once. If you want to poll this value please use the parameter getOpts.pollInterval at ZwaveDevice#registerCapability

Parameters

Name Type Description
capabilityId
string

The string id of the Homey capability

commandClassId
string

The Z-Wave command class used for this request

Returns

Promise.<any>

registerCapability

registerCapability(capabilityId, commandClassId, userOptsopt)

Register a Homey Capability with a Command Class. Multiple parser methods can be provided by appending a version, e.g. getParserV3. This will make sure that the highest matching version will be used, falling back to getParser.

Parameters

Name Type Description
capabilityId
string

The Homey capability id (e.g. onoff)

commandClassId
string

The command class id (e.g. BASIC)

userOpts
object <optional>

The object with options for this capability/commandclass combination. These will extend system options, if available (/system/).

get
string <optional>

The command to get a value (e.g. BASIC_GET)

getParser
string <optional>

The function that is called when a GET request is made. Should return an Object.

getOpts
object <optional>
getOnStart
boolean <optional>

Get the value on App start. Avoid using this option, it should only be used for values that the device does not automatically report.

getOnOnline
boolean <optional>

Only for battery devices, get the value on device wake up. Avoid using this option, it should only be used for values that the device does not automatically report.

pollInterval
number | string <optional>

Interval (in ms) to poll with a GET request. When provided a string, the device's setting with the string as ID will be used (e.g. poll_interval).

pollMultiplication
number <optional>

Multiplication factor for the pollInterval key, must be a number. (e.g. 1000 to convert to seconds, 60.000 for minutes, 3600000 for hours).

}
set
string <optional>

The command to set a value (e.g. BASIC_SET)

setParser
function <optional>

The function that is called when a SET request is made. Should return an Object.

value
number | boolean | string <optional>

The value of the Homey capability

opts
any <optional>

Options for the capability command

}
setOpts
object <optional>
fn
function <optional>

This function is called after a setCapabilityValue has been resolved.

value
any <optional>

The capability value

opts
any <optional>

The capability opts

}
}
report
string <optional>

The command to report a value (e.g. BASIC_REPORT)

reportParserOverride
boolean <optional>

Boolean flag to determine if the reportParser method should override all report parsers. (Assumed false when not specified).

reportParser
function <optional>

The function that is called when a REPORT request is made. Should return an Object.

report
any <optional>

The report object

}
multiChannelNodeId
number <optional>

An ID to use a MultiChannel Node for this capability.

}

registerMultiChannelReportListener

registerMultiChannelReportListener(multiChannelNodeId, commandClassId, commandId, triggerFn)

Register a multi channel report listener, which is called when a report has been received.

Parameters

Name Type Description
multiChannelNodeId
number

The multi channel node id

commandClassId
string

The ID of the Command Class (e.g. BASIC)

commandId
string

The ID of the Command (e.g. BASIC_REPORT)

triggerFn
function
report
any

The received report

}

registerReportListener

registerReportListener(commandClassId, commandId, triggerFn)

Register a report listener, which is called when a report has been received.

Parameters

Name Type Description
commandClassId
string

The ID of the Command Class (e.g. BASIC)

commandId
string

The ID of the Command (e.g. BASIC_REPORT)

triggerFn
function
report
any

The received report

}

registerSetting

registerSetting(settingId, parserFn)

Register a setting parser, which is called when a setting has changed. This is only needed for Z-Wave settings, which directly map between a Homey setting and a Z-Wave parameter.

Parameters

Name Type Description
settingId
string

The setting ID, as specified in /app.json

parserFn
function

The parser function, must return a Buffer, number or boolean

value
number | boolean | string | object

The setting value

zwaveObj
object

The setting's zwave object as defined in /app.json

}