resolve null usage

This commit is contained in:
Marcus Westin 2020-01-15 09:33:39 +00:00
parent 8ab4da0cae
commit c7da3b210b

View file

@ -147,7 +147,7 @@ class PlejdService extends EventEmitter {
this._turnOff(id); this._turnOff(id);
return; return;
} }
this._turnOn(id, currentBrightness); this._turnOn(id, currentBrightness);
i++; i++;
@ -253,17 +253,28 @@ class PlejdService extends EventEmitter {
clearInterval(this.pingRef); clearInterval(this.pingRef);
this.device.removeAllListeners('servicesDiscover'); if (this.device) {
this.device.removeAllListeners('connect'); this.device.removeAllListeners('servicesDiscover');
this.device.removeAllListeners('disconnect'); this.device.removeAllListeners('connect');
this.characteristics.auth.removeAllListeners('read'); this.device.removeAllListeners('disconnect');
this.characteristics.auth.removeAllListeners('write'); }
this.characteristics.data.removeAllListeners('read'); if (this.characteristics.auth) {
this.characteristics.data.removeAllListeners('write'); this.characteristics.auth.removeAllListeners('read');
this.characteristics.lastData.removeAllListeners('read'); this.characteristics.auth.removeAllListeners('write');
this.characteristics.lastData.removeAllListeners('write'); }
this.characteristics.ping.removeAllListeners('read'); if (this.characteristics.data) {
this.characteristics.ping.removeAllListeners('write'); this.characteristics.data.removeAllListeners('read');
this.characteristics.data.removeAllListeners('write');
}
if (this.characteristics.lastData) {
this.characteristics.lastData.removeAllListeners('read');
this.characteristics.lastData.removeAllListeners('write');
}
if (this.characteristics.ping) {
this.characteristics.ping.removeAllListeners('read');
this.characteristics.ping.removeAllListeners('write');
}
this.connectEventHooked = false; this.connectEventHooked = false;