moved listening to plejd events

This commit is contained in:
Marcus Westin 2020-01-20 14:08:43 +00:00
parent ce84a296ab
commit 58041b1d99

View file

@ -160,8 +160,12 @@ class PlejdService extends EventEmitter {
setTimeout(async () => {
await this.onDeviceConnected(connectedDevice);
await this.adapter.StopDiscovery();
// After we've authenticated, we need to hook up the event listener
// for changes to lastData.
this.characteristics.lastDataProperties.on('PropertiesChanged', this.onLastDataUpdated.bind(this));
this.characteristics.lastData.StartNotify();
}, 2000);
}
@ -482,11 +486,6 @@ class PlejdService extends EventEmitter {
onDeviceCharacteristicsComplete() {
logger('onDeviceCharacteristicsComplete()');
this.authenticate();
// After we've authenticated, we need to hook up the event listener
// for changes to lastData.
this.characteristics.lastDataProperties.on('PropertiesChanged', this.onLastDataUpdated.bind(this));
this.characteristics.lastData.StartNotify();
}
async onLastDataUpdated(iface, properties, invalidated) {