Skip to content

Commit

Permalink
Create fan-speed.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mouth4war authored Dec 17, 2019
1 parent a9e8c59 commit 22939ce
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/devices/capabilities/fan-speed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

const { Thing } = require('abstract-things');
const { FanSpeed } = require('abstract-things/climate');

module.exports = Thing.mixin(Parent => class extends Parent.with(FanSpeed) {
fs1 = -1;
fs2 = -1;
propertyUpdated(key, value) {
let updated = false;
if (key === 'fanSpeed1') {
this.fs1 = value;
updated = true;
}
if (key === 'fanSpeed2') {
this.fs2 = value;
updated = true;
}

if(updated) {
const value = this.fs2 || this.fs1;
if(value !== -1) {
this.updateFanSpeed(value);
}
}

super.propertyUpdated(key, value);
}
});

0 comments on commit 22939ce

Please sign in to comment.