Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Fixed an issue where an "Uncleared Alarm" status would show as "Alarm Triggered" in HomeKit.
- Removed "Uncleared Alarm" check from Armed Away, Armed Stay, and Armed Night modes.
- Fixed an issue where an unknown lastState would crash Homebridge.
- Updated documentation of ADT Pulse arm/disarm URLs.
  • Loading branch information
mrjackyliang committed Nov 5, 2019
1 parent 86ab698 commit 7261b8c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
8 changes: 3 additions & 5 deletions adt-pulse.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,9 @@ Pulse.prototype.setDeviceStatus = function (armState, arm) {
* Pulse URLs to set device status.
*
* Notes:
* - When disarming, the armState will be set to "disarmed" (normally it is "off") until next login.
* - Arming with armState "off" (while armState is "disarmed") works.
* - When Disarming, the armState will be set to "disarmed". After re-login, it will be set to "off".
* - When Arming Night, armState will be set to "night+stay". After re-login, it will be set to "night".
* - If alarm occurred, you must Clear Alarm before setting to Armed Away/Stay/Night.
*
* Disarmed:
* - Arm Away (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=disarmed&arm=away)
Expand All @@ -431,13 +432,10 @@ Pulse.prototype.setDeviceStatus = function (armState, arm) {
* - Clear Alarm (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=disarmed+with+alarm&arm=off)
* Armed Away:
* - Disarm (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=away&arm=off)
* - Clear Alarm (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=disarmed+with+alarm&arm=off)
* Armed Stay:
* - Disarm (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=stay&arm=off)
* - Clear Alarm (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=disarmed+with+alarm&arm=off)
* Armed Night:
* - Disarm (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=night&arm=off)
* - Clear Alarm (https://portal.adtpulse.com/myhome/quickcontrol/armDisarm.jsp?href=rest/adt/ui/client/security/setArmState&armstate=disarmed+with+alarm&arm=off)
*
* @type {string}
*/
Expand Down
30 changes: 9 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,23 +849,23 @@ ADTPulsePlatform.prototype.formatDeviceStatus = function (summary) {
let status = null;

let lowerCaseSummary = summary.toLowerCase();
let disarmed = lowerCaseSummary.includes("disarmed");
let uncleared_alarm = lowerCaseSummary.includes("uncleared alarm");
let alarm = lowerCaseSummary.includes("alarm");
let arm_away = lowerCaseSummary.includes("armed away");
let arm_stay = lowerCaseSummary.includes("armed stay");
let arm_night = lowerCaseSummary.includes("armed night");
let uncleared_alarm = lowerCaseSummary.includes("uncleared alarm");
let disarmed = lowerCaseSummary.includes("disarmed");

if (alarm) {
if (disarmed || uncleared_alarm) {
status = Characteristic.SecuritySystemCurrentState.DISARMED;
} else if (alarm) {
status = Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED;
} else if (arm_away) {
status = Characteristic.SecuritySystemCurrentState.AWAY_ARM;
} else if (arm_stay) {
status = Characteristic.SecuritySystemCurrentState.STAY_ARM;
} else if (arm_night) {
status = Characteristic.SecuritySystemCurrentState.NIGHT_ARM;
} else if (uncleared_alarm || disarmed) {
status = Characteristic.SecuritySystemCurrentState.DISARMED;
}

return status;
Expand Down Expand Up @@ -936,11 +936,7 @@ ADTPulsePlatform.prototype.setDeviceStatus = function (accessory, arm, callback)
this.logMessage(`${name} (${id}) is currently armed away...`, 40);

// Clear the alarms first.
if (lastState.includes("uncleared alarm")) {
this.logMessage(`Clearing the ${name} (${id}) alarm...`, 40);

await this.theAlarm.setDeviceStatus("disarmed+with+alarm", "off");
} else if (lastState.includes("alarm")) {
if (lastState.includes("alarm")) {
this.logMessage(`Disarming and clearing the ${name} (${id}) alarm...`, 40);

await this.theAlarm.setDeviceStatus("away", "off");
Expand Down Expand Up @@ -977,11 +973,7 @@ ADTPulsePlatform.prototype.setDeviceStatus = function (accessory, arm, callback)
this.logMessage(`${name} (${id}) is currently armed stay...`, 40);

// Clear the alarms first.
if (lastState.includes("uncleared alarm")) {
this.logMessage(`Clearing the ${name} (${id}) alarm...`, 40);

await this.theAlarm.setDeviceStatus("disarmed+with+alarm", "off");
} else if (lastState.includes("alarm")) {
if (lastState.includes("alarm")) {
this.logMessage(`Disarming and clearing the ${name} (${id}) alarm...`, 40);

await this.theAlarm.setDeviceStatus("stay", "off");
Expand Down Expand Up @@ -1018,11 +1010,7 @@ ADTPulsePlatform.prototype.setDeviceStatus = function (accessory, arm, callback)
this.logMessage(`${name} (${id}) is currently armed night...`, 40);

// Clear the alarms first.
if (lastState.includes("uncleared alarm")) {
this.logMessage(`Clearing the ${name} (${id}) alarm...`, 40);

await this.theAlarm.setDeviceStatus("disarmed+with+alarm", "off");
} else if (lastState.includes("alarm")) {
if (lastState.includes("alarm")) {
this.logMessage(`Disarming and clearing the ${name} (${id}) alarm...`, 40);

await this.theAlarm.setDeviceStatus("night", "off");
Expand Down Expand Up @@ -1056,7 +1044,7 @@ ADTPulsePlatform.prototype.setDeviceStatus = function (accessory, arm, callback)
break;
}
} else {
throw "lastState throw: " + lastState;
this.logMessage(`lastState context with "${lastState}" is unknown.`, 10);
}
})
.then(() => {
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-adt-pulse",
"version": "1.3.0",
"version": "1.3.1",
"description": "Homebridge security system platform for ADT Pulse",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 7261b8c

Please sign in to comment.