diff --git a/plejd/ble.js b/plejd/ble.js index 64bc31c..7ac6bdc 100644 --- a/plejd/ble.js +++ b/plejd/ble.js @@ -617,11 +617,16 @@ class PlejdService extends EventEmitter { unsubscribeCharacteristics() { if (this.characteristics.lastData) { - this.characteristics.lastData.unsubscribe((err) => { - if (err) { - console.log('error: could not unsubscribe from event.'); - } - }); + try { + this.characteristics.lastData.unsubscribe((err) => { + if (err) { + console.log('error: could not unsubscribe from event.'); + } + }); + } + catch (error) { + console.log('warning: could not unsubscribe from lastData, probably already disconnected: ' + error); + } } } diff --git a/plejd/config.json b/plejd/config.json index 1b1eb14..faee13a 100644 --- a/plejd/config.json +++ b/plejd/config.json @@ -1,6 +1,6 @@ { "name": "Plejd", - "version": "0.2.6", + "version": "0.2.7", "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 17ca62b..d44e7b2 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'); -const version = "0.2.6"; +const version = "0.2.7"; async function main() { console.log('starting Plejd add-on v. ' + version);