Skip to content

Commit

Permalink
Fix trip switch not resetting during mode changes in triggered state (#…
Browse files Browse the repository at this point in the history
…615)

Fix trip switch not resetting during mode changes
  • Loading branch information
MiguelRipoll23 authored Nov 10, 2024
1 parent c49cee5 commit 2060b5f
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,13 +970,9 @@ SecuritySystem.prototype.resetTimers = function () {
};

SecuritySystem.prototype.handleTargetStateChange = function (origin) {
// Clear arming timeout
clearTimeout(this.armTimeout);

// Reset double-knock
this.isKnocked = false;

this.resetTimers();
this.resetTripSwitches();
this.resetTrippedMotionSensor();
this.resetModeSwitches();
this.updateModeSwitches();

Expand All @@ -994,18 +990,10 @@ SecuritySystem.prototype.handleTargetStateChange = function (origin) {

if (isCurrentStateAlarmTriggered) {
this.triggerResetSensor();

// Keep characteristic & switches on
return;
}

// Reset tripped motion sensor
if (this.tripSwitchService.getCharacteristic(Characteristic.On).value) {
this.updateTripSwitch(false, originTypes.INTERNAL, true, null);
}

// Reset trip switches
this.resetTripSwitches();
// Reset double-knock
this.isKnocked = false;
};

SecuritySystem.prototype.isBadTargetState = function (state) {
Expand Down Expand Up @@ -2227,6 +2215,12 @@ SecuritySystem.prototype.resetModeSwitches = function () {
}
};

SecuritySystem.prototype.resetTrippedMotionSensor = function () {
if (this.tripSwitchService.getCharacteristic(Characteristic.On).value) {
this.updateTripSwitch(false, originTypes.INTERNAL, true, null);
}
};

SecuritySystem.prototype.updateModeSwitches = function () {
switch (this.targetState) {
case Characteristic.SecuritySystemTargetState.STAY_ARM:
Expand Down

0 comments on commit 2060b5f

Please sign in to comment.