Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into production (#minor) #139

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions lib/ZwaveDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@

// Non z-wave settings: see if there is a function to execute, otherwise do nothing.
if (typeof manifestSetting === 'undefined') {
if (this._settings.hasOwnProperty(changedKey)) {

Check warning on line 198 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 198 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
const parser = this._settings[changedKey];

if (typeof parser === 'function') parser.call(this, newValue);
Expand All @@ -212,7 +212,7 @@
id: changedKey,
index: manifestSetting.index,
size: manifestSetting.size,
signed: manifestSetting.hasOwnProperty('signed') ? manifestSetting.signed : true,

Check warning on line 215 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 215 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
},
newSettings[changedKey],
);
Expand Down Expand Up @@ -246,13 +246,13 @@

if (typeof message !== 'object' && typeof message !== 'string') {
this._debug("Save message's return value is not an object nor a string");
} else if (typeof message === 'object' && !message.hasOwnProperty('en')) {

Check warning on line 249 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 249 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
this._debug('A custom save message needs at least the english translation');
} else {
saveMessage = message;
}
} else if (typeof this.customSaveMessage === 'object') {
if (!this.customSaveMessage.hasOwnProperty('en')) {

Check warning on line 255 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 255 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
this._debug('A custom save message needs at least the english translation');
} else {
saveMessage = this.customSaveMessage;
Expand Down Expand Up @@ -871,7 +871,7 @@
if (command.name === 'CENTRAL_SCENE_NOTIFICATION') {
if (
typeof previousSequence !== 'undefined'
&& payload.hasOwnProperty('Sequence Number')

Check warning on line 874 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 874 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
&& payload['Sequence Number'] === previousSequence
) {
return;
Expand All @@ -879,8 +879,8 @@
previousSequence = payload['Sequence Number'];

if (
payload.hasOwnProperty('Properties1')

Check warning on line 882 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 882 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
&& payload.Properties1.hasOwnProperty('Key Attributes')

Check warning on line 883 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 883 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
&& typeof payload.Properties1['Key Attributes'] === 'number'
) {
switch (payload.Properties1['Key Attributes']) {
Expand Down Expand Up @@ -1045,11 +1045,15 @@
/**
* 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 } = {}) {
async meterReset({ multiChannelNodeId } = {}, options = {}) {
// Get command class object (on mc node if needed)
let commandClassMeter = null;
if (typeof multiChannelNodeId === 'number') {
Expand All @@ -1058,8 +1062,24 @@
commandClassMeter = this.getCommandClass('METER');
}

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

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
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
Expand All @@ -1083,7 +1103,7 @@
* @returns {Promise<any>}
*/
async configurationSet(options = {}, value) {
if (!options.hasOwnProperty('index') && !options.hasOwnProperty('id')) {

Check warning on line 1106 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 1106 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 1106 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object

Check warning on line 1106 in lib/ZwaveDevice.js

View workflow job for this annotation

GitHub Actions / Lint

Do not access Object.prototype method 'hasOwnProperty' from target object
return Promise.reject(new Error('missing_setting_index_or_id'));
}
if (options.hasOwnProperty('index') && !options.hasOwnProperty('size')) {
Expand Down
Loading