Skip to content

Commit

Permalink
#384 sort input
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoduj committed Dec 31, 2021
1 parent 086ad43 commit fd004c2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
19 changes: 19 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions harmonySubPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit fd004c2

Please sign in to comment.