@homenet/plugin-zway
Version:
Homenet plugin for Z-Way connected Z-Wave devices
40 lines • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const node_zway_1 = require("node-zway");
const CLASS_LOCK = 98;
const CLASS_SENSOR_BINARY = 48;
const CLASS_SENSOR_MULTI = 49;
const CLASS_ALARM = 113;
const CLASS_BATTERY = 128;
class ZwayController {
constructor(id, host = 'localhost', user = 'admin', password = 'password', port = 8083) {
this._deviceApi = new node_zway_1.DeviceApi({ host, port, user, password });
this._deviceApi.poll(5000);
}
start() {
this._deviceApi.refresh();
}
onSensorBinaryEvent(deviceId, callback) {
this._deviceApi.on(deviceId, String(CLASS_SENSOR_BINARY), '*', callback);
}
onSensorMultiEvent(deviceId, callback) {
this._deviceApi.on(deviceId, String(CLASS_SENSOR_MULTI), '*', callback);
}
onLockEvent(deviceId, callback) {
this._deviceApi.on(deviceId, String(CLASS_LOCK), '*', callback);
}
onAlarmEvent(deviceId, callback) {
this._deviceApi.on(deviceId, String(CLASS_ALARM), '*', callback);
}
getDevice(deviceId) {
return this._deviceApi.getDevice(deviceId);
}
getLockDevice(deviceId) {
return this._deviceApi.getDevice(deviceId, CLASS_LOCK);
}
getSensorDevice(deviceId) {
return this._deviceApi.getDevice(deviceId, [CLASS_SENSOR_BINARY, CLASS_SENSOR_MULTI, CLASS_BATTERY]);
}
}
exports.ZwayController = ZwayController;
//# sourceMappingURL=controller.js.map