homecontrol-control-base/SwitchBase.js
2019-01-29 21:48:53 +01:00

30 lines
507 B
JavaScript

const HCControlBase = require('./ControlBase');
const SwitchState = require('./states/SwitchState');
class HCSwitchBase extends HCControlBase {
constructor(config) {
super(config, new SwitchState());
}
get type() {
return "switch";
}
turnOn() {
return Promise.reject("Not implemented");
}
turnOff() {
return Promise.reject("Not implemented");
}
togglePower() {
if(this.state.on) {
return this.turnOff();
} else {
return this.turnOn();
}
}
}
module.exports = HCSwitchBase;