From 7261b8cf49eb7371fe01a489957ba3b5a790c91a Mon Sep 17 00:00:00 2001 From: Jacky Liang Date: Tue, 5 Nov 2019 12:26:09 -0500 Subject: [PATCH] Bug fixes - 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. --- adt-pulse.js | 8 +++----- index.js | 30 +++++++++--------------------- package.json | 2 +- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/adt-pulse.js b/adt-pulse.js index 29e22c0..15114b2 100644 --- a/adt-pulse.js +++ b/adt-pulse.js @@ -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) @@ -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} */ diff --git a/index.js b/index.js index 933bcf6..561f727 100644 --- a/index.js +++ b/index.js @@ -849,14 +849,16 @@ 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; @@ -864,8 +866,6 @@ ADTPulsePlatform.prototype.formatDeviceStatus = function (summary) { 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; @@ -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"); @@ -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"); @@ -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"); @@ -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(() => { diff --git a/package.json b/package.json index 2f89061..282710a 100644 --- a/package.json +++ b/package.json @@ -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": {