From a387aa0bf4a8c7dbc414cb5cb787de67ee82e323 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Jan 2020 17:03:26 +0100 Subject: [PATCH] added more logging and created new version --- plejd/ble.js | 23 +++++++++++++---------- plejd/config.json | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/plejd/ble.js b/plejd/ble.js index a643f56..8cc70e1 100644 --- a/plejd/ble.js +++ b/plejd/ble.js @@ -163,7 +163,7 @@ class PlejdService extends EventEmitter { } scan() { - logger('scan()'); + console.log('scan()'); if (this.state === STATE_SCANNING) { console.log('error: already scanning, please wait.'); @@ -178,7 +178,7 @@ class PlejdService extends EventEmitter { this.state = STATE_IDLE; const foundDeviceCount = Object.values(this.devices).length; - logger('scan completed, found ' + foundDeviceCount + ' device(s).'); + console.log('scan completed, found ' + foundDeviceCount + ' device(s).'); if (foundDeviceCount == 0) { console.log('warning: no devices found. will not do anything else.'); @@ -243,12 +243,12 @@ class PlejdService extends EventEmitter { } reset() { - logger('reset()'); + console.log('reset()'); this.state = STATE_IDLE; } disconnect() { - logger('disconnect()'); + console.log('disconnect()'); if (this.state !== STATE_CONNECTED && this.state !== STATE_AUTHENTICATED) { return; } @@ -266,7 +266,7 @@ class PlejdService extends EventEmitter { } authenticate() { - logger('authenticate()'); + console.log('authenticate()'); const self = this; if (this.state !== STATE_CONNECTED) { @@ -323,7 +323,7 @@ class PlejdService extends EventEmitter { } startPing() { - logger('startPing()'); + console.log('startPing()'); clearInterval(this.pingRef); this.pingRef = setInterval(async () => { @@ -399,7 +399,7 @@ class PlejdService extends EventEmitter { } onDeviceConnected(err) { - logger('onDeviceConnected()'); + console.log('onDeviceConnected()'); const self = this; if (err) { @@ -500,17 +500,20 @@ class PlejdService extends EventEmitter { } onDeviceScanComplete() { - logger('onDeviceScanComplete()'); + console.log('onDeviceScanComplete()'); console.log('trying to connect to the mesh network.'); this.connect(); } onInterfaceStateChanged(state) { - logger('onInterfaceStateChanged(' + state + ')'); + console.log('onInterfaceStateChanged(' + state + ')'); if (state === 'poweredOn') { this.scan(); } + else { + noble.stopScanning(); + } } onLastDataUpdated(data, isNotification) { @@ -556,7 +559,7 @@ class PlejdService extends EventEmitter { } wireEvents() { - logger('wireEvents()'); + console.log('wireEvents()'); const self = this; noble.on('stateChange', this.onInterfaceStateChanged.bind(self)); diff --git a/plejd/config.json b/plejd/config.json index a2140bf..33cf466 100644 --- a/plejd/config.json +++ b/plejd/config.json @@ -1,6 +1,6 @@ { "name": "Plejd", - "version": "0.2.0", + "version": "0.2.1", "slug": "plejd", "description": "Adds support for the Swedish home automation devices from Plejd.", "url": "https://github.com/icanos/hassio-plejd/",