diff --git a/plejd/PlejdBLEHandler.js b/plejd/PlejdBLEHandler.js index 58ea552..9256324 100644 --- a/plejd/PlejdBLEHandler.js +++ b/plejd/PlejdBLEHandler.js @@ -199,7 +199,9 @@ class PlejBLEHandler extends EventEmitter { plejd.device = this.deviceRegistry.getDeviceBySerialNumber(fixedPlejdPath); if (plejd.device) { - logger.debug(`Discovered ${plejd.path} with rssi ${plejd.rssi}, name ${plejd.device.name}`); + logger.debug( + `Discovered ${plejd.path} with rssi ${plejd.rssi} dBm, name ${plejd.device.name}`, + ); this.bleDevices.push(plejd); } else { logger.warn(`Device registry does not contain device with serial ${fixedPlejdPath}`); @@ -359,9 +361,9 @@ class PlejBLEHandler extends EventEmitter { } async _powerOffAdapter() { - logger.verbose('Powering off BLE adapter and waiting 5 seconds'); + logger.verbose('Powering off BLE adapter and waiting 30 seconds'); await this.adapterProperties.Set(BLUEZ_ADAPTER_ID, 'Powered', new dbus.Variant('b', 0)); - await delay(5000); + await delay(30000); } async _cleanExistingConnections(managedObjects) { @@ -501,9 +503,15 @@ class PlejBLEHandler extends EventEmitter { this.cleanup(); this.consecutiveReconnectAttempts++; + + if (this.consecutiveReconnectAttempts % 100 === 0) { + logger.error('Failed reconnecting 100 times. Creating a new dbus instance...'); + this.bus = dbus.systemBus(); + } + if (this.consecutiveReconnectAttempts % 10 === 0) { logger.warn( - `Tried reconnecting ${this.consecutiveReconnectAttempts} times. Try power cycling the BLE adapter every 10th time...`, + `Tried reconnecting ${this.consecutiveReconnectAttempts} times. Will power cycle the BLE adapter now...`, ); await this._powerCycleAdapter(); } else { diff --git a/plejd/README.md b/plejd/README.md index 3a16cf0..5c91796 100644 --- a/plejd/README.md +++ b/plejd/README.md @@ -147,6 +147,8 @@ If you're having issues to get the addon working, there are a few things you can - Start `bluetoothctl` interactive command - Write `list` and make sure it finds the Bluetooth device. If no device is found you need to fix this first! - Look in Plejd addon log and make sure there is no `unable to find a bluetooth adapter` line +- Make sure signal strength is "good enough". The BLE adapter needs to be reasonably close to a Plejd device. Look at the RSSI reading in the debug logs. In some cases an RSSI of -80 dBm works well, in other cases a higher value such as -40 dBm is required to work. +- You should get verbose/debug logs similar to: `Found Plejd service on ...` => `Discovered ... with RSSI ...` => `Inspecting ...` => `Connecting ...` => `Connected` => `Connected device is a Plejd device ...` => `BLE Connected to ...` => `Bluetooth connected. Plejd BLE up and running!`. After this sequence (which could fail multiple times before finally succeeding) you should get quite frequent `Raw event received ...` from the Plejd mesh. When updating state you should see in the logs `Sending 8 byte(s) of data to Plejd ...`. - Listen to `#` in the MQTT integration and watch Plejd mqtt messages come in - Initial device discovery messages originate from the Plejd API, so if you set up that correctly you should get new devices in HA - Plejd log will show something like `discovered light (DIM-01) named ....` diff --git a/plejd/config.json b/plejd/config.json index eeeff6c..e0a2043 100644 --- a/plejd/config.json +++ b/plejd/config.json @@ -1,6 +1,6 @@ { "name": "Plejd", - "version": "0.6.2", + "version": "0.7.0", "slug": "plejd", "description": "Adds support for the Swedish home automation devices from Plejd.", "url": "https://github.com/icanos/hassio-plejd/",