From 9ab689e4ba73a80b8acfa74e43e9ba7a32479e01 Mon Sep 17 00:00:00 2001 From: aficustree Date: Tue, 13 Feb 2018 08:53:04 -0600 Subject: [PATCH 1/9] testing the swap of updateCharacteristic instead of setCharacteristic --- index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index fbb0bdd..b7941ba 100644 --- a/index.js +++ b/index.js @@ -238,7 +238,7 @@ class AlarmdecoderPlatform { this.alarmDecoderSystem.state = 3; if(report) this.alarmDecoderSystem.accessory.getService(Service.SecuritySystem) - .setCharacteristic(Characteristic.SecuritySystemCurrentState, this.alarmDecoderSystem.state); + .updateCharacteristic(Characteristic.SecuritySystemCurrentState, this.alarmDecoderSystem.state); // set alarm state for(let alarmZone in this.alarmDecoderZones) { alarmZone=this.alarmDecoderZones[alarmZone]; @@ -249,32 +249,32 @@ class AlarmdecoderPlatform { if(report) { if(alarmZone.accessory.getService(Service.MotionSensor)) { alarmZone.accessory.getService(Service.MotionSensor) - .setCharacteristic(Characteristic.MotionDetected, alarmZone.faulted); + .updateCharacteristic(Characteristic.MotionDetected, alarmZone.faulted); } else if(alarmZone.accessory.getService(Service.ContactSensor)) { if(alarmZone.faulted) alarmZone.accessory.getService(Service.ContactSensor) - .setCharacteristic(Characteristic.ContactSensorState, 1); + .updateCharacteristic(Characteristic.ContactSensorState, 1); else alarmZone.accessory.getService(Service.ContactSensor) - .setCharacteristic(Characteristic.ContactSensorState, 0); + .updateCharacteristic(Characteristic.ContactSensorState, 0); } else if(alarmZone.accessory.getService(Service.CarbonMonoxideSensor)) { if(alarmZone.faulted) alarmZone.accessory.getService(Service.CarbonMonoxideSensor) - .setCharacteristic(Characteristic.CarbonMonoxideDetected, 1); + .updateCharacteristic(Characteristic.CarbonMonoxideDetected, 1); else alarmZone.accessory.getService(Service.CarbonMonoxideSensor) - .setCharacteristic(Characteristic.CarbonMonoxideDetected, 0); + .updateCharacteristic(Characteristic.CarbonMonoxideDetected, 0); } else if(alarmZone.accessory.getService(Service.SmokeSensor)) { this.log('zone is a smoke sensor, status is '+alarmZone.faulted); if(alarmZone.faulted) alarmZone.accessory.getService(Service.SmokeSensor) - .setCharacteristic(Characteristic.SmokeDetected, 1); + .updateCharacteristic(Characteristic.SmokeDetected, 1); else alarmZone.accessory.getService(Service.SmokeSensor) - .setCharacteristic(Characteristic.SmokeDetected, 0); + .updateCharacteristic(Characteristic.SmokeDetected, 0); } } } From 544e868f958f2771f379c3a1956b5e8c0cf94095 Mon Sep 17 00:00:00 2001 From: aficustree Date: Sun, 29 Apr 2018 13:49:18 -0500 Subject: [PATCH 2/9] adding debug code to trim logs, bumping package.json --- index.js | 21 ++++++++++----------- package.json | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index b7941ba..135ae42 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ var Accessory, Service, Characteristic, UUIDGen; var axios = require('axios'); +var debug = require('debug'); module.exports = function(homebridge){ Accessory = homebridge.platformAccessory; @@ -205,14 +206,14 @@ class AlarmdecoderPlatform { data += chunk; }); req.on('end', () => { - this.log('Received notification and body data:'); + debug('Received notification and body data:'); if(this.debug) - this.log(data.toString()); + debug(data.toString()); }); } res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(); - this.log('Getting current state since ping received'); + debug('Getting current state since ping received'); this.getState(true); } @@ -224,8 +225,7 @@ class AlarmdecoderPlatform { if(stateObj.last_message_received && (stateObj.last_message_received.includes('NIGHT') || stateObj.last_message_received.includes('INSTANT'))) stateObj.panel_armed_night = true; /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */ - if(this.debug) - this.log(stateObj); + debug(stateObj); if(stateObj.panel_alarming || stateObj.panel_panicked) this.alarmDecoderSystem.state = 4; else if(stateObj.panel_armed_night) @@ -268,7 +268,7 @@ class AlarmdecoderPlatform { .updateCharacteristic(Characteristic.CarbonMonoxideDetected, 0); } else if(alarmZone.accessory.getService(Service.SmokeSensor)) { - this.log('zone is a smoke sensor, status is '+alarmZone.faulted); + debug('zone is a smoke sensor, status is '+alarmZone.faulted); if(alarmZone.faulted) alarmZone.accessory.getService(Service.SmokeSensor) .updateCharacteristic(Characteristic.SmokeDetected, 1); @@ -287,7 +287,7 @@ class AlarmdecoderPlatform { } getZoneState(displayName, callback) { - this.log('getting state for '+displayName); + debug('getting state for '+displayName); this.getState(false); //don't publish state as it's being called from homekit and the callback will update instead var found = false; for(let alarmZone in this.alarmDecoderZones) { @@ -306,13 +306,13 @@ class AlarmdecoderPlatform { } } if(found==false) { - this.log('zone '+displayName+' not found'); + debug('zone '+displayName+' not found'); callback('no zone found',null); } } getAlarmState(callback) { - this.log('getting state for '+this.name); + debug('getting state for '+this.name); this.getState(false); if(this.alarmDecoderSystem.state!=null) { callback(null,this.alarmDecoderSystem.state); @@ -341,8 +341,7 @@ class AlarmdecoderPlatform { var tempObj = new Object(); tempObj.keys=codeToSend; var body = JSON.stringify(tempObj); - if(this.debug) - this.log(body); + debug(body); try { // ignore disarm requests if panel is already disarmed and it's a DSC panel (otherwise it rearms itself) if(this.isDSC && (state == Characteristic.SecuritySystemTargetState.DISARM) && (this.alarmDecoderSystem.state == 3)) diff --git a/package.json b/package.json index 3deb5df..2678058 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "homebridge-alarmdecoder-platform", "version": "1.2.0", "description": "An http-based contact and motion sensor plugin for homebridge: https://github.com/nfarina/homebridge, for use with alarmdecoder. Exposes honeywell/dsc alarm system, motion and contact sensors when used with alarmdecoder.", - "license": "Apache 2.0", + "license": "Apache-2.0", "keywords": [ "homebridge-plugin", "homebridge", From 1f0e7f264d7efbd2567232e8fe6d67237efbf0d3 Mon Sep 17 00:00:00 2001 From: aficustree Date: Sun, 29 Apr 2018 13:51:31 -0500 Subject: [PATCH 3/9] bumping package --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2678058..dea018e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-alarmdecoder-platform", - "version": "1.2.0", + "version": "1.2.1", "description": "An http-based contact and motion sensor plugin for homebridge: https://github.com/nfarina/homebridge, for use with alarmdecoder. Exposes honeywell/dsc alarm system, motion and contact sensors when used with alarmdecoder.", "license": "Apache-2.0", "keywords": [ @@ -21,7 +21,8 @@ "url": "https://github.com/aficustree/homebridge-alarmdecoder-platform.git" }, "dependencies": { - "axios": "^0.17.1" + "axios": "^0.17.1", + "debug": "^3.0.0" }, "readmeFilename": "README.md", "bugs": { From e0183ae359e838a771acbc8bb23030982db6f81a Mon Sep 17 00:00:00 2001 From: aficustree Date: Sun, 29 Apr 2018 18:22:14 -0500 Subject: [PATCH 4/9] minor fix --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 135ae42..b41c5e2 100644 --- a/index.js +++ b/index.js @@ -225,7 +225,7 @@ class AlarmdecoderPlatform { if(stateObj.last_message_received && (stateObj.last_message_received.includes('NIGHT') || stateObj.last_message_received.includes('INSTANT'))) stateObj.panel_armed_night = true; /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */ - debug(stateObj); + debug(stateObj.toString()); if(stateObj.panel_alarming || stateObj.panel_panicked) this.alarmDecoderSystem.state = 4; else if(stateObj.panel_armed_night) From 3f25f005b1820d572d7946a5531a542af63430ac Mon Sep 17 00:00:00 2001 From: aficustree Date: Tue, 1 May 2018 12:47:57 -0500 Subject: [PATCH 5/9] testing changes to alarm set callback --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b41c5e2..fe46825 100644 --- a/index.js +++ b/index.js @@ -348,12 +348,12 @@ class AlarmdecoderPlatform { throw('disarm request for DSC panel but system is already disarmed, ignoring'); var response = await axios.post(this.setURL,body,this.axiosHeaderConfig); if(response.status==200 || response.status==204) //should be a 204 - callback(null, response, state); + callback(null); else throw('set failed'); } catch (err) { - callback('set failed',response,this.alarmDecoderSystem.state); + callback(err); this.log(err); } } From ae2c740d7fee28e37ae5a1a363da815ea214dc0a Mon Sep 17 00:00:00 2001 From: aficustree Date: Tue, 1 May 2018 13:00:05 -0500 Subject: [PATCH 6/9] bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dea018e..bfe022b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-alarmdecoder-platform", - "version": "1.2.1", + "version": "1.2.11", "description": "An http-based contact and motion sensor plugin for homebridge: https://github.com/nfarina/homebridge, for use with alarmdecoder. Exposes honeywell/dsc alarm system, motion and contact sensors when used with alarmdecoder.", "license": "Apache-2.0", "keywords": [ From 8a4c956a608e9a7d4a871d89d6cf51a0066592c8 Mon Sep 17 00:00:00 2001 From: aficustree Date: Tue, 1 May 2018 13:25:52 -0500 Subject: [PATCH 7/9] test --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fe46825..74d83bb 100644 --- a/index.js +++ b/index.js @@ -225,7 +225,7 @@ class AlarmdecoderPlatform { if(stateObj.last_message_received && (stateObj.last_message_received.includes('NIGHT') || stateObj.last_message_received.includes('INSTANT'))) stateObj.panel_armed_night = true; /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */ - debug(stateObj.toString()); + this.log(stateObj.toString()); if(stateObj.panel_alarming || stateObj.panel_panicked) this.alarmDecoderSystem.state = 4; else if(stateObj.panel_armed_night) @@ -325,7 +325,7 @@ class AlarmdecoderPlatform { this.log('setting alarm state to '+state); var codeToSend = null; switch (state) { - case Characteristic.SecuritySystemTargetState.STAY_ARM: + case Characteristic.SecuritySystemTargetState.STAY_ARM: //home codeToSend = this.isDSC ? this.DSCStay : this.setPIN+'3'; break; case Characteristic.SecuritySystemTargetState.AWAY_ARM : From 112f3e57ceb9267732d912b10850e52029d463c9 Mon Sep 17 00:00:00 2001 From: aficustree Date: Tue, 1 May 2018 13:34:51 -0500 Subject: [PATCH 8/9] more debug code --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 74d83bb..511211b 100644 --- a/index.js +++ b/index.js @@ -225,7 +225,7 @@ class AlarmdecoderPlatform { if(stateObj.last_message_received && (stateObj.last_message_received.includes('NIGHT') || stateObj.last_message_received.includes('INSTANT'))) stateObj.panel_armed_night = true; /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */ - this.log(stateObj.toString()); + this.log(JSON.stringify(stateObj)); if(stateObj.panel_alarming || stateObj.panel_panicked) this.alarmDecoderSystem.state = 4; else if(stateObj.panel_armed_night) From 2545d14324c5053a594b37b44590fa66efee90e8 Mon Sep 17 00:00:00 2001 From: aficustree Date: Mon, 18 Jun 2018 09:51:27 -0500 Subject: [PATCH 9/9] minor debug --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 511211b..cd865c6 100644 --- a/index.js +++ b/index.js @@ -226,7 +226,7 @@ class AlarmdecoderPlatform { stateObj.panel_armed_night = true; /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */ this.log(JSON.stringify(stateObj)); - if(stateObj.panel_alarming || stateObj.panel_panicked) + if(stateObj.panel_alarming || stateObj.panel_panicked || stateObj.panel_fire_detected) this.alarmDecoderSystem.state = 4; else if(stateObj.panel_armed_night) this.alarmDecoderSystem.state = 2;