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

fix(meter-reset): return after success #123

Merged
merged 3 commits into from
Nov 9, 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
3 changes: 3 additions & 0 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
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
},
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
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
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
&& 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
&& 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
&& typeof payload.Properties1['Key Attributes'] === 'number'
) {
switch (payload.Properties1['Key Attributes']) {
Expand Down Expand Up @@ -1058,9 +1058,12 @@
commandClassMeter = this.getCommandClass('METER');
}

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

Check warning on line 1061 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 (result !== 'TRANSMIT_COMPLETE_OK') throw result;

// Return if reset was successful
return;
}
throw new Error('missing_meter_reset_command');
}
Expand All @@ -1080,7 +1083,7 @@
* @returns {Promise<any>}
*/
async configurationSet(options = {}, value) {
if (!options.hasOwnProperty('index') && !options.hasOwnProperty('id')) {

Check warning on line 1086 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 1086 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