From 9950f8b0c8e83a84d9fb27fc7135d0f4febe445d Mon Sep 17 00:00:00 2001 From: Nicolas Dujardin Date: Wed, 27 Mar 2019 22:05:12 +0100 Subject: [PATCH] 0.7.0 --- README.md | 2 +- harmonyBase.js | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c26bdef..7ab8d59 100755 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Fields: - `publishDevicesAsIndividualAccessories` option to publish devices as individual accessories. Defaults to true. - `sequencesToPublishAsAccessoriesSwitch` array of Sequences to exposes through a switch. - `publishSequencesAsIndividualAccessories` option to publish sequences as individual accessories. Defaults to true. -- `publishHomeControlButtons` set to true if you want to publish home controls as switches +- `homeControlsToPublishAsAccessoriesSwitch` array of home controls you want to publish as switches - `publishHomeControlsAsIndividualAccessories` option to publish home controls as individual accessories. Defaults to true. - `TVPlatformMode` option to try TV mode . STILL WORK IN PROGRESS - NEEDS IOS 12.2 / HOMEBRIDGE 0.0.46 - `mainActivity` set the mainactivity of the TV mode diff --git a/harmonyBase.js b/harmonyBase.js index d09afc2..7be5ecc 100644 --- a/harmonyBase.js +++ b/harmonyBase.js @@ -42,8 +42,8 @@ HarmonyBase.prototype = { true ); - harmonyPlatform.publishHomeControlButtons = - config['publishHomeControlButtons']; + harmonyPlatform.homeControlsToPublishAsAccessoriesSwitch = + config['homeControlsToPublishAsAccessoriesSwitch']; harmonyPlatform.publishHomeControlsAsIndividualAccessories = HarmonyTools.checkParameter( config['publishHomeControlsAsIndividualAccessories'], true @@ -608,7 +608,10 @@ HarmonyBase.prototype = { }, getHomeControlsAccessories: function(harmonyPlatform) { - if (harmonyPlatform.publishHomeControlButtons) { + if ( + harmonyPlatform.homeControlsToPublishAsAccessoriesSwitch && + harmonyPlatform.homeControlsToPublishAsAccessoriesSwitch.length > 0 + ) { harmonyPlatform.log.debug('INFO - getting home controls ...'); return this.harmony.getAutomationCommands(); } else { @@ -637,26 +640,33 @@ HarmonyBase.prototype = { for (var key in homeControls) { let switchName = key; - let accessoryName = harmonyPlatform.name + '-' + switchName; - if (harmonyPlatform.devMode) { - switchName = 'DEV' + switchName; - } + if ( + harmonyPlatform.homeControlsToPublishAsAccessoriesSwitch.includes( + switchName + ) + ) { + let accessoryName = harmonyPlatform.name + '-' + switchName; - harmonyPlatform.log('INFO - Discovered Home Control : ' + switchName); + if (harmonyPlatform.devMode) { + switchName = 'DEV' + switchName; + } - let service = { - controlService: new Service.Switch(switchName), - characteristics: [Characteristic.On], - }; - service.controlService.subtype = switchName; - service.controlService.id = key; - service.type = HarmonyConst.HOME_TYPE; - services.push(service); + harmonyPlatform.log('INFO - Discovered Home Control : ' + switchName); - if (harmonyPlatform.publishHomeControlsAsIndividualAccessories) { - this.publishAccessory(harmonyPlatform, services, accessoryName); - services = []; + let service = { + controlService: new Service.Switch(switchName), + characteristics: [Characteristic.On], + }; + service.controlService.subtype = switchName; + service.controlService.id = key; + service.type = HarmonyConst.HOME_TYPE; + services.push(service); + + if (harmonyPlatform.publishHomeControlsAsIndividualAccessories) { + this.publishAccessory(harmonyPlatform, services, accessoryName); + services = []; + } } }