diff --git a/lib/ZwaveDevice.js b/lib/ZwaveDevice.js index d4e893a..1c3407d 100644 --- a/lib/ZwaveDevice.js +++ b/lib/ZwaveDevice.js @@ -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} */ - async meterReset({ multiChannelNodeId } = {}) { + async meterReset({ multiChannelNodeId } = {}, options = {}) { // Get command class object (on mc node if needed) let commandClassMeter = null; if (typeof multiChannelNodeId === 'number') { @@ -1059,7 +1063,23 @@ class ZwaveDevice extends Homey.Device { } if (commandClassMeter && commandClassMeter.hasOwnProperty('METER_RESET')) { - const result = await commandClassMeter.METER_RESET({}); + if (commandClassMeter.version >= 6 && Object.keys(options).length === 0) { + options = { + Properties1: { + 'Scale bit 2': false, + 'Rate Type': 0, + 'Meter Type': 'Electric meter', + }, + Properties2: { + Size: 1, + 'Scale bits 10': 0, + Precision: 0, + }, + 'Meter Value': Buffer.from([0]), + 'Scale 2': 0, + }; + } + const result = await commandClassMeter.METER_RESET(options); if (result !== 'TRANSMIT_COMPLETE_OK') throw result; // Return if reset was successful