30 lines
507 B
JavaScript
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; |