Skip to content

Commit

Permalink
0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoduj committed Mar 27, 2019
1 parent cd12902 commit 9950f8b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 29 additions & 19 deletions harmonyBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ HarmonyBase.prototype = {
true
);

harmonyPlatform.publishHomeControlButtons =
config['publishHomeControlButtons'];
harmonyPlatform.homeControlsToPublishAsAccessoriesSwitch =
config['homeControlsToPublishAsAccessoriesSwitch'];
harmonyPlatform.publishHomeControlsAsIndividualAccessories = HarmonyTools.checkParameter(
config['publishHomeControlsAsIndividualAccessories'],
true
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = [];
}
}
}

Expand Down

0 comments on commit 9950f8b

Please sign in to comment.