From 0fa82e36810358cde1f53032e015b58d3cd8e2b7 Mon Sep 17 00:00:00 2001 From: icanos Date: Fri, 24 Jan 2020 17:30:17 +0000 Subject: [PATCH] potential bug fixed and new version --- plejd/ble.bluez.js | 9 +++++---- plejd/config.json | 2 +- plejd/main.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plejd/ble.bluez.js b/plejd/ble.bluez.js index 3ddaa8f..7fec31e 100644 --- a/plejd/ble.bluez.js +++ b/plejd/ble.bluez.js @@ -450,21 +450,22 @@ class PlejdService extends EventEmitter { console.log('onDeviceConnected()'); const objects = await this.objectManager.GetManagedObjects(); + const paths = Object.keys(objects); let characteristics = []; - for (const path of Object.keys(objects)) { + for (const path of paths) { const interfaces = Object.keys(objects[path]); if (interfaces.indexOf(GATT_CHRC_ID) > -1) { characteristics.push(path); } } - for (const path of Object.keys(objects)) { + for (const path of paths) { const interfaces = Object.keys(objects[path]); if (interfaces.indexOf(GATT_SERVICE_ID) > -1) { let chPaths = []; for (const c of characteristics) { - if (c[0] === '/') { + if (c.startsWith(path + '/')) { chPaths.push(c); } } @@ -485,7 +486,7 @@ class PlejdService extends EventEmitter { } if (!this.characteristics.auth) { - console.log('plejd-ble: error: unable to connect to the Plejd mesh.'); + console.log('plejd-ble: error: unable to enumerate characteristics.'); this.emit('connectFailed'); return; } diff --git a/plejd/config.json b/plejd/config.json index 48dae09..d5e312a 100644 --- a/plejd/config.json +++ b/plejd/config.json @@ -1,6 +1,6 @@ { "name": "Plejd", - "version": "0.3.1", + "version": "0.3.2", "slug": "plejd", "description": "Adds support for the Swedish home automation devices from Plejd.", "url": "https://github.com/icanos/hassio-plejd/", diff --git a/plejd/main.js b/plejd/main.js index 9d5db05..291de76 100644 --- a/plejd/main.js +++ b/plejd/main.js @@ -3,7 +3,7 @@ const mqtt = require('./mqtt'); const fs = require('fs'); const PlejdService = require('./ble.bluez'); -const version = "0.3.1"; +const version = "0.3.2"; async function main() { console.log('starting Plejd add-on v. ' + version);