homecontrol-control-base/ControlBase.js
2020-08-06 00:18:48 +02:00

65 lines
1.2 KiB
JavaScript

const { EventEmitter } = require('events');
const BaseState = require('./states/BaseState');
class HCControlBase extends EventEmitter {
/**
* @param {Object} configuration
* @param {BaseState} state
*/
constructor(configuration, state) {
super();
if (!configuration.name) throw new Error("Device name is missing");
this._configuration = configuration;
this._state = state;
this._name = this._configuration.name;
}
static get _is_homecontrol_control() {
return true;
}
static get version() {
return "n/a";
}
get state() {
return this._state.clone();
}
get type() {
return "none";
}
get name() {
return this._name;
}
/**
* Run some sort of asynchronous initialization
* @returns A promise which resolves when the initialization is complete
*/
init() {
return Promise.resolve();
}
/**
* Run some sort of asynchronous de-initialization/cleanup
* @returns A promise which resolves when the de-initialization is complete
*/
deinit() {
return Promise.resolve();
}
/**
* Updates the state by polling the controlled device
* @returns A promise which resolves when the state has been pulled
*/
pullState() {
return Promise.resolve();
}
}
module.exports = HCControlBase;