From c3cf88ef8f4c18530043ed9a382d01bd027f9d77 Mon Sep 17 00:00:00 2001 From: Nicolas Dujardin Date: Thu, 22 Aug 2019 19:42:28 +0200 Subject: [PATCH] 1.0.5 --- CHANGELOG.md | 4 ++++ harmonyPlatform.js | 36 +++++++++++++++++++----------------- harmonySubPlatform.js | 4 ++-- package.json | 2 +- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16d0052..7face18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 1.0.5 + +- [FIX] trying to better handle some problems with clean cache / name caching + ## 1.0.4 - [FIX] sequencesToPublishAsAccessoriesSwitch switches don't do anything #165 diff --git a/harmonyPlatform.js b/harmonyPlatform.js index 2daa03a..db3f335 100644 --- a/harmonyPlatform.js +++ b/harmonyPlatform.js @@ -57,7 +57,24 @@ function HarmonyPlatform(log, config, api) { let platform = this.platforms[i]; platform.harmonyBase.harmony.removeAllListeners(); platform.harmonyBase.harmony.close(); + + if (this.cleanCache) + { + this.log( + 'WARNING - shutdown - cleaning cache.' + ); + + this.api.unregisterPlatformAccessories( + 'homebridge-harmonyHub', + 'HarmonyHubWebSocket', + platform._foundAccessories + ); + } + } + + + }.bind(this) ) .on( @@ -65,21 +82,6 @@ function HarmonyPlatform(log, config, api) { function() { this.log('DidFinishLaunching'); - if (this.cleanCache) { - this.log('WARNING - Removing Accessories'); - this.api.unregisterPlatformAccessories( - 'homebridge-harmonyHub', - 'HarmonyHubWebSocket', - this._foundAccessories - ); - this._foundAccessories = []; - - for (let i = 0, len = this.platforms.length; i < len; i++) { - let platform = this.platforms[i]; - platform._foundAccessories = []; - } - } - for (let i = 0, len = this.platforms.length; i < len; i++) { let platform = this.platforms[i]; platform.harmonyBase.configureAccessories(platform); @@ -98,10 +100,10 @@ HarmonyPlatform.prototype = { if (this.platforms && this.platforms.length > 0) platform = this.platforms.find(x => x.name == platformName); - if (platform == undefined) + if (platform == undefined || this.cleanCache || this.config == undefined) { this.log( - 'WARNING - configureAccessory - The platform ' + platformName + ' is not there anymore in your config (name property). It won\'t be loaded and will be removed from cache.' + 'WARNING - configureAccessory - The platform ' + platformName + ' is not there anymore in your config (name property) or cleanCached set to true. It won\'t be loaded and will be removed from cache.' ); this.api.unregisterPlatformAccessories( diff --git a/harmonySubPlatform.js b/harmonySubPlatform.js index a2f4e6b..006b38e 100644 --- a/harmonySubPlatform.js +++ b/harmonySubPlatform.js @@ -294,7 +294,7 @@ HarmonySubPlatform.prototype = { accessory.addService(this.mainService); } - if (this.savedNames && this.savedNames[0]) { + if (this.savedNames && this.savedNames[0] && this.savedNames[0] !== "" ) { mainServiceName = this.savedNames[0]; } else { mainServiceName = this.name; @@ -400,7 +400,7 @@ HarmonySubPlatform.prototype = { inputSourceService ); - if (this.savedNames && this.savedNames[inputId]) { + if (this.savedNames && this.savedNames[inputId] && this.savedNames[inputId]!== "") { inputServiceName = this.savedNames[inputId]; } else { inputServiceName = inputName; diff --git a/package.json b/package.json index 1e7b477..1523ed2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-harmony", - "version": "1.0.4", + "version": "1.0.5", "author": "Nicolas Dujardin", "description": "Publish your harmony activities as homekit accessories", "main": "index.js",