homenet-plugin-zway
Version:
Homenet plugin for Z-Way connected Z-Wave devices
29 lines • 984 B
JavaScript
;
const node_zway_1 = require('node-zway');
const CLASS_LOCK = 98;
class ZwayController {
constructor(id, host = 'localhost', user = 'admin', password = 'password', port = 8083) {
this._deviceApi = new node_zway_1.DeviceApi({ host: host, port: port, user: user, password: password });
this._deviceApi.poll(5000);
}
start() {
this._deviceApi.refresh();
}
onSensorEvent(deviceId, callback) {
this._deviceApi.on(deviceId, '48', '*', callback);
}
onLockEvent(deviceId, callback) {
this._deviceApi.on(deviceId, '98', '*', callback);
}
onAlarmEvent(deviceId, callback) {
this._deviceApi.on(deviceId, '113', '*', callback);
}
getDevice(deviceId) {
return this._deviceApi.getDevice(deviceId);
}
getLockDevice(deviceId) {
return this._deviceApi.getDevice(deviceId, CLASS_LOCK);
}
}
exports.ZwayController = ZwayController;
//# sourceMappingURL=controller.js.map