Skip to content

Commit

Permalink
Prevent recursive device calls for hallLightHome. Fix bad object prop…
Browse files Browse the repository at this point in the history
… in smartthingsModeChange
  • Loading branch information
imbrianj committed Dec 31, 2016
1 parent 9f16cd9 commit 8f9d0fc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions apps/hallLightHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ module.exports = (function () {
'use strict';

return {
version : 20161101,
version : 20161231,

lastEvents : { presence : 0, open : 0 },
lastEvents : { acted : 0, presence : 0, open : 0 },

hallLightHome : function (deviceId, command, controllers, values, config) {
var deviceState = require(__dirname + '/../lib/deviceState'),
Expand Down Expand Up @@ -68,7 +68,7 @@ module.exports = (function () {
this.lastEvents.open = now;
}

if ((now < delay + this.lastEvents.presence) && (now < delay + this.lastEvents.open)) {
if ((now > delay + this.lastEvents.acted) && (now < delay + this.lastEvents.presence) && (now < delay + this.lastEvents.open)) {
if (config.macro) {
for (macro in rawMacro) {
if (rawMacro.hasOwnProperty(macro)) {
Expand All @@ -88,12 +88,17 @@ module.exports = (function () {
case 'raspberryRemote' :
currentDeviceState = deviceState.getDeviceState(currDevice);
break;

default :
currentDeviceState = null;
}

if ((currentDeviceState.value) && (currentDeviceState.value.devices)) {
for (subdevice in currentDeviceState.value.devices) {
if (config.action.indexOf(currentDeviceState.value.devices[subdevice].label) !== -1) {
runCommand.runCommand(currDevice, 'subdevice-' + currentDeviceState.value.devices[subdevice].label + '-on');
this.lastEvents.acted = now;

runCommand.runCommand(currDevice, 'subdevice-' + currentDeviceState.value.devices[subdevice].label + '-on', currDevice);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/smartthingsModeChange.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = (function () {

// If you have a macro assigned to this specific Mode, we'll act
// upon it.
if (config[SmartthingsMode[deviceId]]) {
if (config[newMode]) {
runCommand = require(__dirname + '/../lib/runCommand');

rawMacro = config[newMode].split(';');
Expand Down
2 changes: 1 addition & 1 deletion cache/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1483166364855
1483181551680
2 changes: 1 addition & 1 deletion js/combo.min.js

Large diffs are not rendered by default.

0 comments on commit 8f9d0fc

Please sign in to comment.