Class: ZwaveMeteringDevice

ZwaveMeteringDevice()

The ZwaveMeteringDevice class. Warning, the METER_RESET FlowCardAction should not be used, remove the FlowCard from your app manifest

Constructor

new ZwaveMeteringDevice()

Example
// device.js
const ZwaveMeteringDevice = require('homey-meshdriver').ZwaveMeteringDevice;

class myDevice extends ZwaveMeteringDevice {

 async onMeshInit() {
     await super.onMeshInit();
     this.registerCapability('measure_power', 'METER');
     this.registerCapability('meter_power', 'METER');
 }
}

Extends

Methods

(async) configurationGet(options) → {*}

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

Parameters:
Name Type Description
options Object
Properties
Name Type Description
index number

Parameter index

Inherited From:
Returns:
Type
*

(async) configurationSet(options, value) → {Promise.<*>}

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
Properties
Name Type Attributes Default Description
index
size
id
signed <optional>
useSettingParser <optional>
true
value
Inherited From:
Returns:
Type
Promise.<*>

disableDebug()

Disable debugging to the console

Inherited From:

enableDebug()

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

Inherited From:

(async) executeCapabilitySetCommand(capabilityId, commandClassId, value, opts) → {Promise.<(string|*)>}

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 Mixed

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

opts Object

capability options object

Inherited From:
Returns:
Type
Promise.<(string|*)>

getCommandClass(commandClassId, opts) → {Error|boolean|*}

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
Properties
Name Type Description
multiChannelNodeId Number

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

Inherited From:
Returns:
Type
Error | boolean | *

getManifestSetting(id) → {Object|Error}

Get a specific setting object from the manifest

Parameters:
Name Type Description
id

Setting id to retrieve

Inherited From:
Returns:
Type
Object | Error

getManifestSettings() → {Array}

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

Inherited From:
Returns:
Type
Array

getMultiChannelNodeIdsByDeviceClassGeneric(deviceClassGeneric) → {Array}

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

Parameters:
Name Type Description
deviceClassGeneric String
Inherited From:
Returns:
Type
Array

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
Properties
Name Type Description
multiChannelNodeId number

Multi channel node id to check for command class

Inherited From:
Returns:
Type
boolean

(async) meterReset(multiChannelNodeId) → {Promise.<unknown>}

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.

Parameters:
Name Type Description
multiChannelNodeId

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

Inherited From:
Returns:
Type
Promise.<unknown>

onDeleted()

Remove all listeners and intervals from node

Inherited From:

(async) onSettings(oldSettings, newSettings, changedKeysArr) → {Promise.<T>}

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
Inherited From:
Returns:
Type
Promise.<T>

printNode()

Print the current Node information with Command Classes and their versions

Inherited From:

(async) refreshCapabilityValue(capabilityId,, commandClassId,) → {Promise.<unknown>}

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

Inherited From:
Returns:
Type
Promise.<unknown>

registerCapability(capabilityId, commandClassId, optsopt)

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 Attributes Description
capabilityId string

The Homey capability id (e.g. onoff)

commandClassId string

The command class id (e.g. BASIC)

opts Object <optional>

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

Properties
Name Type Attributes Description
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
Properties
Name Type Attributes Description
getOnStart Boolean <optional>

Get the value on App start

getOnOnline Boolean <optional>

Get the value when the device is marked as online

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.

Properties
Name Type Attributes Description
value Mixed <optional>

The value of the Homey capability

opts Object <optional>

Options for the capability command

fn function <optional>

This function is called after a setCapabilityValue has been called

Properties
Name Type Attributes Description
value Object <optional>

The capability value

opts Object <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.

Properties
Name Type Attributes Description
report Object <optional>

The report object

multiChannelNodeId Number <optional>

An ID to use a MultiChannel Node for this capability

fn function <optional>

This function is called after a setCapabilityValue has been executed

Properties
Name Type Attributes Description
value Object <optional>

The capability value

Inherited From:

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
Properties
Name Type Description
report Object

The received report

Inherited From:

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
Properties
Name Type Description
report Object

The received report

Inherited From:

registerSetting(settingId, parserFn)

Register a setting parser, which is called when a setting has changed.

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

Properties
Name Type Description
value Mixed

The setting value

zwaveObj Mixed

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

Inherited From: