Merge pull request #51 from icanos/bluez

potential bug fixed and new version
This commit is contained in:
Marcus Westin 2020-01-24 18:30:45 +01:00 committed by GitHub
commit 7b1bbc6a92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View file

@ -450,21 +450,22 @@ class PlejdService extends EventEmitter {
console.log('onDeviceConnected()'); console.log('onDeviceConnected()');
const objects = await this.objectManager.GetManagedObjects(); const objects = await this.objectManager.GetManagedObjects();
const paths = Object.keys(objects);
let characteristics = []; let characteristics = [];
for (const path of Object.keys(objects)) { for (const path of paths) {
const interfaces = Object.keys(objects[path]); const interfaces = Object.keys(objects[path]);
if (interfaces.indexOf(GATT_CHRC_ID) > -1) { if (interfaces.indexOf(GATT_CHRC_ID) > -1) {
characteristics.push(path); characteristics.push(path);
} }
} }
for (const path of Object.keys(objects)) { for (const path of paths) {
const interfaces = Object.keys(objects[path]); const interfaces = Object.keys(objects[path]);
if (interfaces.indexOf(GATT_SERVICE_ID) > -1) { if (interfaces.indexOf(GATT_SERVICE_ID) > -1) {
let chPaths = []; let chPaths = [];
for (const c of characteristics) { for (const c of characteristics) {
if (c[0] === '/') { if (c.startsWith(path + '/')) {
chPaths.push(c); chPaths.push(c);
} }
} }
@ -485,7 +486,7 @@ class PlejdService extends EventEmitter {
} }
if (!this.characteristics.auth) { 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'); this.emit('connectFailed');
return; return;
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "Plejd", "name": "Plejd",
"version": "0.3.1", "version": "0.3.2",
"slug": "plejd", "slug": "plejd",
"description": "Adds support for the Swedish home automation devices from Plejd.", "description": "Adds support for the Swedish home automation devices from Plejd.",
"url": "https://github.com/icanos/hassio-plejd/", "url": "https://github.com/icanos/hassio-plejd/",

View file

@ -3,7 +3,7 @@ const mqtt = require('./mqtt');
const fs = require('fs'); const fs = require('fs');
const PlejdService = require('./ble.bluez'); const PlejdService = require('./ble.bluez');
const version = "0.3.1"; const version = "0.3.2";
async function main() { async function main() {
console.log('starting Plejd add-on v. ' + version); console.log('starting Plejd add-on v. ' + version);