From 5048a4ee7c98469e738832070eb012c71f0d7793 Mon Sep 17 00:00:00 2001 From: Nicolas Dujardin Date: Sun, 17 Mar 2019 22:30:56 +0100 Subject: [PATCH] 0.5.4 --- CHANGELOG.md | 4 +++ harmonyAsSwitches.js | 21 +++------------- harmonyAsTVPlatform.js | 57 ++++++++++++++++-------------------------- harmonyBase.js | 14 ++++++----- harmonyTools.js | 2 +- package.json | 2 +- 6 files changed, 39 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63e202b..f5dffd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 0.5.4 + +- [BUG] - Devices are not published if publishDevicesAsIndividualAccessories is set to false #106 + ## 0.5.3 - [NEW] handle skipedIfSameStateActivities for POWER OFF in TV mode #104 - Just add "PowerOff" to the skipedIfSameStateActivities. diff --git a/harmonyAsSwitches.js b/harmonyAsSwitches.js index 8fa95a8..934d4aa 100644 --- a/harmonyAsSwitches.js +++ b/harmonyAsSwitches.js @@ -15,7 +15,7 @@ function HarmonyPlatformAsSwitches(log, config, api) { this.harmonyBase.configCommonProperties(log, config, api, this); this.showTurnOffActivity = config['showTurnOffActivity']; - this.publishActivitiesAsIndividualAccessories = HarmonyTools.checkParemeter( + this.publishActivitiesAsIndividualAccessories = HarmonyTools.checkParameter( config['publishActivitiesAsIndividualAccessories'], true ); @@ -44,22 +44,6 @@ HarmonyPlatformAsSwitches.prototype = { this._foundAccessories.push(myHarmonyAccessory); }, - readOptionnalAccessories: function(data) { - if ( - this.devicesToPublishAsAccessoriesSwitch && - this.devicesToPublishAsAccessoriesSwitch.length > 0 - ) { - this.harmonyBase.getDevicesAccessories(this, data); - } - - if ( - this.sequencesToPublishAsAccessoriesSwitch && - this.sequencesToPublishAsAccessoriesSwitch.length > 0 - ) { - this.harmonyBase.getSequencesAccessories(this, data); - } - }, - showActivity: function(activity) { return activity.id != -1 || this.showTurnOffActivity; }, @@ -98,7 +82,8 @@ HarmonyPlatformAsSwitches.prototype = { this.addAccessory(services, this.name); } - this.readOptionnalAccessories(data); + this.harmonyBase.getDevicesAccessories(this, data); + this.harmonyBase.getSequencesAccessories(this, data); //first refresh diff --git a/harmonyAsTVPlatform.js b/harmonyAsTVPlatform.js index 01e1597..79ab1f9 100644 --- a/harmonyAsTVPlatform.js +++ b/harmonyAsTVPlatform.js @@ -18,7 +18,7 @@ function HarmonyPlatformAsTVPlatform(log, config, api) { this.harmonyBase = new HarmonyBase(api); this.harmonyBase.configCommonProperties(log, config, api, this); this.mainActivity = config['mainActivity']; - this.playPauseBehavior = HarmonyTools.checkParemeter( + this.playPauseBehavior = HarmonyTools.checkParameter( config['playPauseBehavior'], false ); @@ -61,22 +61,7 @@ function HarmonyPlatformAsTVPlatform(log, config, api) { HarmonyPlatformAsTVPlatform.prototype = { onMessage(newActivity) { - this.updateCurrentInputService(newActivity); - - this.harmonyBase.handleCharacteristicUpdate( - this, - this.mainService.controlService.getCharacteristic(Characteristic.Active), - this._currentActivity > 0, - null - ); - this.harmonyBase.handleCharacteristicUpdate( - this, - this.mainService.controlService.getCharacteristic( - Characteristic.ActiveIdentifier - ), - this._currentActivity, - null - ); + this.handleRefreshOfCharacteristic(newActivity); }, ///CREATION / STARTUP @@ -290,26 +275,28 @@ HarmonyPlatformAsTVPlatform.prototype = { ///REFRESHING TOOLS + handleRefreshOfCharacteristic(activity) { + this.updateCurrentInputService(activity); + + this.harmonyBase.handleCharacteristicUpdate( + this, + this.mainService.controlService.getCharacteristic(Characteristic.Active), + this._currentActivity > 0, + null + ); + this.harmonyBase.handleCharacteristicUpdate( + this, + this.mainService.controlService.getCharacteristic( + Characteristic.ActiveIdentifier + ), + this._currentActivity, + null + ); + }, + refreshAccessory: function() { this.harmonyBase.refreshCurrentActivity(this, () => { - this.updateCurrentInputService(this._currentActivity); - - this.harmonyBase.handleCharacteristicUpdate( - this, - this.mainService.controlService.getCharacteristic( - Characteristic.Active - ), - this._currentActivity > 0, - null - ); - this.harmonyBase.handleCharacteristicUpdate( - this, - this.mainService.controlService.getCharacteristic( - Characteristic.ActiveIdentifier - ), - this._currentActivity, - null - ); + this.handleRefreshOfCharacteristic(this._currentActivity); }); }, diff --git a/harmonyBase.js b/harmonyBase.js index dbcdf95..8325812 100644 --- a/harmonyBase.js +++ b/harmonyBase.js @@ -30,7 +30,7 @@ HarmonyBase.prototype = { harmonyPlatform.devicesToPublishAsAccessoriesSwitch = config['devicesToPublishAsAccessoriesSwitch']; - harmonyPlatform.publishDevicesAsIndividualAccessories = HarmonyTools.checkParemeter( + harmonyPlatform.publishDevicesAsIndividualAccessories = HarmonyTools.checkParameter( config['publishDevicesAsIndividualAccessories'], true ); @@ -38,7 +38,7 @@ HarmonyBase.prototype = { harmonyPlatform.sequencesToPublishAsAccessoriesSwitch = config['sequencesToPublishAsAccessoriesSwitch']; - harmonyPlatform.publishSequencesAsIndividualAccessories = HarmonyTools.checkParemeter( + harmonyPlatform.publishSequencesAsIndividualAccessories = HarmonyTools.checkParameter( config['publishSequencesAsIndividualAccessories'], true ); @@ -561,7 +561,7 @@ HarmonyBase.prototype = { harmonyPlatform.devicesToPublishAsAccessoriesSwitch.length > 0 ) { harmonyPlatform.log('INFO - Loading devices...'); - let services = []; + var services = []; for ( let c = 0, @@ -581,7 +581,8 @@ HarmonyBase.prototype = { //default mode if (commands.length === 1) { - services.concat( + services.push.apply( + services, this.handleDefaultCommandMode( harmonyPlatform, controlGroup, @@ -591,7 +592,8 @@ HarmonyBase.prototype = { } //specifc command or list mode else { - services.concat( + services.push.apply( + services, this.handleSpecificCommandMode( harmonyPlatform, commands, @@ -609,7 +611,7 @@ HarmonyBase.prototype = { services.length > 0 ) { harmonyPlatform.log( - 'INFO - Adding Accessory : ' + harmonyPlatform.name + 'INFO - Adding Accessory : ' + harmonyPlatform.name + '-Devices' ); let myHarmonyAccessory = new HarmonyTools.HarmonyAccessory(services); myHarmonyAccessory.getServices = function() { diff --git a/harmonyTools.js b/harmonyTools.js index 4ccef9b..9c1f1fa 100644 --- a/harmonyTools.js +++ b/harmonyTools.js @@ -1,7 +1,7 @@ const HarmonyConst = require('./harmonyConst'); module.exports = { - checkParemeter: function(parameter, def) { + checkParameter: function(parameter, def) { if (parameter == undefined) return def; else return parameter; }, diff --git a/package.json b/package.json index d24f079..108a25b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-harmony", - "version": "0.5.3", + "version": "0.5.4", "author": "Nicolas Dujardin", "description": "Publish your harmony activities as homekit accessories", "main": "index.js",