diff --git a/CHANGELOG.md b/CHANGELOG.md index 3151f97..3b50149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 1.5.4 + +- [NEW] Option for sorting activities either alphabetically or by activity order in harmony conf (thx to @alapitz PR - Sort the activities alphabetically #384) + ## 1.5.3 - [FIX] PLAY and PAUSE commands not working #363 diff --git a/README.md b/README.md index 9a2dc39..1932cca 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ Fields: - `hubName` is the name of your hub in harmony app (optional, but mandatory if you have mutliple hubs). In case both hubName and hubIP are not set, it will discover your hub automatically, providing there is only one - `hubIP` is the static IP address of the hub (optional). A static IP address is required. - `TVAccessory` publish hub with its activities as a TV Accessory (defaults to true). +- `SortInput` sort input list in TV accessory : 0-default,1:Alpha,2:activityOrder property(defaults to 0). - `switchAccessories` publish all activities as a Switch Accessory (defaults to false). - `activitiesToPublishAsAccessoriesSwitch` array of Activities you want to expose as switches (all by default if switchAccessories is set to true, otherwise specify the list you want) - `showTurnOffActivity` configures whether to publish a "switch" accessory to turn off every activity (defaults to false). diff --git a/config.schema.json b/config.schema.json index d623150..42c8461 100644 --- a/config.schema.json +++ b/config.schema.json @@ -55,6 +55,13 @@ "title": "TV accessory in homekit (Defaults to true if not set)", "type": "boolean" }, + "SortInput": { + "title": "sort input list in TV accessory : 0-default,1:Alpha,2:activityOrder property (defaults to 0).", + "type": "integer", + "default": 0, + "minimum": 0, + "maximum": 2 + }, "configureAccesscontrol": { "title": "Enable Access Control Service (false by default)", "type": "boolean" @@ -331,6 +338,10 @@ "title": "TV accessory in homekit (Defaults to true if not set)", "type": "boolean" }, + "SortInput": { + "title": "sort input list in TV accessory : 0-default,1:Alpha,2:activityOrder property (defaults to 0).", + "type": "integer" + }, "configureAccesscontrol": { "title": "Enable Access Control Service (false by default)", "type": "boolean" @@ -602,6 +613,10 @@ "key": "TVAccessory", "description": "Publish hub with its activities as a TV Accessory" }, + { + "key": "SortInput", + "description": "sort input list in TV accessory" + }, { "type": "fieldset", "title": "TV Accessory options", @@ -972,6 +987,10 @@ "key": "otherPlatforms[].TVAccessory", "description": "Publish hub with its activities as a TV Accessory" }, + { + "key": "otherPlatforms[].SortInput", + "description": "sort input list in TV accessory" + }, { "type": "fieldset", "title": "TV Accessory options", diff --git a/harmonySubPlatform.js b/harmonySubPlatform.js index 20292f7..9800245 100644 --- a/harmonySubPlatform.js +++ b/harmonySubPlatform.js @@ -23,6 +23,8 @@ function HarmonySubPlatform(log, config, api, mainPlatform) { this.TVAccessory = HarmonyTools.checkParameter(config['TVAccessory'], true); + this.sortInput = HarmonyTools.checkParameter(config['sortInput'], 0); + this.publishGeneralMuteSwitch = HarmonyTools.checkParameter( config['publishGeneralMuteSwitch'], false @@ -248,8 +250,10 @@ HarmonySubPlatform.prototype = { let mainActivityConfigured = false; let defaultActivity = undefined; - //Pre-sort so the input sorces are set alphabetically. - activities.sort((a, b) => a.label.localeCompare(b.label)); + //Pre-sort so the input sorces are set alphabetically or by activityOrder + + if (this.sortInput == 1) activities.sort((a, b) => a.label.localeCompare(b.label)); + else if (this.sortInput > 1) activities.sort((a, b) => a.activityOrder - b.activityOrder); for (let i = 0, len = activities.length; i < len; i++) { if (this.showInput(activities[i])) { diff --git a/package.json b/package.json index 2adc2f5..4bf17d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-harmony", - "version": "1.5.3", + "version": "1.5.4", "author": "Nicolas Dujardin", "description": "Publish your harmony activities as homekit accessories", "main": "index.js",