Skip to content

Commit

Permalink
0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoduj committed Mar 17, 2019
1 parent d69a12b commit 92d8f70
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 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.

## 0.5.3

- [NEW] handle skipedIfSameStateActivities for POWER OFF in TV mode #104 - Just add "PowerOff" to the skipedIfSameStateActivities.

## 0.5.2

- [FIX] ERROR - TVMODE - Override of a command throw an error if there is no device published in devicesToPublishAsAccessoriesSwitch #99
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Fields:
- if you set to true, The "switch" will be "on" if and only if there is no current activity, and toggling it while "on" does nothing.
- if you set to "inverted", The "switch" will be "off" if and only if there is no current activity, and toggling it while "off" does nothing.
- if you set to "stateless", it will always be off, but can be triggered to switch off current activity.
- `skipedIfSameStateActivities` array of Activities name to trigger only if their state is different from the action sent. Can be usefull if your devices in the activity have the same on / off command and you want to automate them outside off the home app
- `skipedIfSameStateActivities` array of Activities name to trigger only if their state is different from the action sent. Can be usefull if your devices in the activity have the same on / off command and you want to automate them outside off the home app . For TV mode, and PowerOff feature, you can add "PowerOff" to this list if you want.
- `addAllActivitiesToSkipedIfSameStateActivitiesList` option to add all activities automatically to skipedIfSameStateActivities behavior. (defaults : false)
- `publishActivitiesAsIndividualAccessories` option to publish activities as individual accessories. Defaults to true.
- `devicesToPublishAsAccessoriesSwitch` array of Devices to exposes with on/off function or custom functions
Expand All @@ -78,6 +78,8 @@ Fields:
- `playPauseBehavior` play/pause behavior in TV mode : if set to true, will send pause if played was set and vice-verca. Be aware that both commands must be available, and that it might be out of sync in case of external events (defaults : false - always send play command)
- `remoteOverrideCommandsList` option to ovverride default commands mapping in TV Platform Mode. See below for format.

All devices / Activites names are the one configured in harmony configuration, even if you rename them in home app.

**Option** `devicesToPublishAsAccessoriesSwitch` is an array that behaves this way :

- You should put the name of the device as it is named in harmony app,
Expand Down
12 changes: 3 additions & 9 deletions harmonyAsSwitches.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,6 @@ HarmonyPlatformAsSwitches.prototype = {
});
},

isActivtyToBeSkipped: function(activity) {
return (
this.addAllActivitiesToSkipedIfSameStateActivitiesList ||
(this.skipedIfSameStateActivities &&
this.skipedIfSameStateActivities.includes(activity))
);
},

setSwitchOnCharacteristic: function(
homebridgeAccessory,
characteristic,
Expand All @@ -321,7 +313,9 @@ HarmonyPlatformAsSwitches.prototype = {
let currentValue = characteristic.value;

//Actitiy in skipedIfSameState
if (this.isActivtyToBeSkipped(service.controlService.subtype)) {
if (
HarmonyTools.isActivtyToBeSkipped(this, service.controlService.subtype)
) {
this.log.debug(
'INFO : SET on an activty in skipedIfsameState list ' +
service.controlService.subtype
Expand Down
17 changes: 4 additions & 13 deletions harmonyAsTVPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,24 +389,19 @@ HarmonyPlatformAsTVPlatform.prototype = {
let doCommand = true;
let commandToSend = value;

let inputName = '';
let inputName = commandToSend == -1 ? 'PowerOff' : '';

for (let i = 0, len = this.inputServices.length; i < len; i++) {
if (this.inputServices[i].activityId == commandToSend) {
inputName = this.inputServices[i].activityName;
break;
}
}

if (
this.addAllActivitiesToSkipedIfSameStateActivitiesList ||
(this.skipedIfSameStateActivities &&
this.skipedIfSameStateActivities.includes(inputName))
) {
if (HarmonyTools.isActivtyToBeSkipped(this, inputName)) {
//GLOBAL OFF SWITCH : do command only if we are not off
if (commandToSend == -1) {
doCommand =
this._currentActivity != -1 &&
this._currentActivity > HarmonyConst.CURRENT_ACTIVITY_NOT_SET_VALUE;
doCommand = this._currentActivity > 0;
}
//ELSE, we do the command only if state is different.
else {
Expand Down Expand Up @@ -520,10 +515,6 @@ HarmonyPlatformAsTVPlatform.prototype = {
}, HarmonyConst.DELAY_BETWEEN_ATTEMPS_STATUS_UPDATE);
}
});
/*
.catch(e => {
this.log('ERROR - activityCommand : ' + e);
});*/
},

handlePlayPause: function() {
Expand Down
8 changes: 8 additions & 0 deletions harmonyTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ module.exports = {
);
},

isActivtyToBeSkipped: function(platform, activity) {
return (
platform.addAllActivitiesToSkipedIfSameStateActivitiesList ||
(platform.skipedIfSameStateActivities &&
platform.skipedIfSameStateActivities.includes(activity))
);
},

processCommands: async function(hb, platform, commands) {
for (const command of commands) {
let commandTosend = command.split('|');
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": "0.5.2",
"version": "0.5.3",
"author": "Nicolas Dujardin",
"description": "Publish your harmony activities as homekit accessories",
"main": "index.js",
Expand Down

0 comments on commit 92d8f70

Please sign in to comment.