Skip to content

Commit

Permalink
Change options property
Browse files Browse the repository at this point in the history
  • Loading branch information
ttherbrink committed Nov 28, 2023
1 parent b8feced commit b7d498b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/ZwaveDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,15 @@ class ZwaveDevice extends Homey.Device {
/**
* 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.
*
* @param multiChannelNodeId - define the multi channel node id in case the
* COMMAND_CLASS_METER is on a multi channel node.
* @param options - options given to the METER_RESET command, Only used when version >= 6
* @returns {Promise<any>}
*/
async meterReset({ multiChannelNodeId } = {}, { options } = {}) {
async meterReset({ multiChannelNodeId } = {}, options = {}) {
// Get command class object (on mc node if needed)
let commandClassMeter = null;
if (typeof multiChannelNodeId === 'number') {
Expand All @@ -1059,11 +1063,7 @@ class ZwaveDevice extends Homey.Device {
}

if (commandClassMeter && commandClassMeter.hasOwnProperty('METER_RESET')) {

Check warning on line 1065 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
if (commandClassMeter.version < 6) {
if (options.length > 0) {
throw new Error('invalid_meter_reset_options');
}
} else {
if (commandClassMeter.version >= 6 && Object.keys(options).length === 0) {
options = {
Properties1: {
'Scale bit 2': false,
Expand All @@ -1077,7 +1077,6 @@ class ZwaveDevice extends Homey.Device {
},
'Meter Value': Buffer.from([0]),
'Scale 2': 0,
...options,
};
}
const result = await commandClassMeter.METER_RESET(options);
Expand Down

0 comments on commit b7d498b

Please sign in to comment.