Skip to content

Commit

Permalink
Allow numbers and strings not beginning with "L" and "H"...
Browse files Browse the repository at this point in the history
...to be valid values for cmdLow and cmdHigh
  • Loading branch information
fra-iesus authored and iRayanKhan committed Mar 1, 2021
1 parent 41d7aa0 commit c156828
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/ConvectorAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class ConvectorAccessory extends BaseAccessory {

this.cmdLow = 'LOW';
if (this.device.context.cmdLow) {
if (/^l[a-z]+$/i.test(this.device.context.cmdLow)) this.cmdLow = ('' + this.device.context.cmdLow).trim();
if (/^[a-z0-9]+$/i.test(this.device.context.cmdLow)) this.cmdLow = ('' + this.device.context.cmdLow).trim();
else throw new Error('The cmdLow doesn\'t appear to be valid: ' + this.device.context.cmdLow);
}

this.cmdHigh = 'HIGH';
if (this.device.context.cmdHigh) {
if (/^h[a-z]+$/i.test(this.device.context.cmdHigh)) this.cmdHigh = ('' + this.device.context.cmdHigh).trim();
if (/^[a-z0-9]+$/i.test(this.device.context.cmdHigh)) this.cmdHigh = ('' + this.device.context.cmdHigh).trim();
else throw new Error('The cmdHigh doesn\'t appear to be valid: ' + this.device.context.cmdHigh);
}

Expand Down Expand Up @@ -310,4 +310,4 @@ class ConvectorAccessory extends BaseAccessory {
}
}

module.exports = ConvectorAccessory;
module.exports = ConvectorAccessory;

0 comments on commit c156828

Please sign in to comment.