From edb591277cd095d7fd55aeeb7aaf7b6953507e6b Mon Sep 17 00:00:00 2001 From: Peter Aquino Date: Sun, 23 May 2021 11:22:56 -0400 Subject: [PATCH 1/3] Refactored the 'hasHumiditySensor' function to account for all currently supported tags --- lib/tag.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/tag.js b/lib/tag.js index 69db1a8..3fdb216 100644 --- a/lib/tag.js +++ b/lib/tag.js @@ -244,9 +244,15 @@ WirelessTag.prototype.hasEventSensor = function() { }; /** Whether the tag has a humidity sensor. */ WirelessTag.prototype.hasHumiditySensor = function() { - if (this.isOutdoorTag()) return false; - if ((this.rev & 0x0F) === 0x0D && this.rev >= 0x4D) return false; - return this.canHighPrecTemp(); + return (this.tagType === 13 + || this.tagType === 21 + || this.tagType === 26 + || this.tagType === 52 + || this.tagType === 72 + || this.tagType === 102 + || this.tagType === 106 + || this.tagType === 107 + ); }; /** Whether the tag has a temperature sensor. */ WirelessTag.prototype.hasTempSensor = function() { @@ -331,6 +337,7 @@ WirelessTag.prototype.canHighPrecTemp = function() { || this.tagType === 26 // ambient light || this.tagType === 72 // PIR || this.tagType === 42 // outdoor tag w/ probe + || this.tagType === 106 // precision ext-power sensor || this.isKumostat() ; }; @@ -389,7 +396,7 @@ WirelessTag.prototype.isWeMo = function() { WirelessTag.prototype.isWeMoLED = function() { return (this.isWeMo() && (this.data.cap > 0)); }; -/** Whether the tab object represents a Dropcam camera. */ +/** Whether the tag object represents a Dropcam camera. */ WirelessTag.prototype.isCamera = function() { return (this.tagType === 92); }; From 744fe8473e09a94395c394df1d50c0436d1c00e7 Mon Sep 17 00:00:00 2001 From: Peter Aquino Date: Mon, 7 Jun 2021 12:00:32 -0700 Subject: [PATCH 2/3] Tags now expose "batteryremaining" property --- lib/sensor.js | 3 +++ lib/tag.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/sensor.js b/lib/sensor.js index a204306..04f1bf6 100644 --- a/lib/sensor.js +++ b/lib/sensor.js @@ -180,6 +180,9 @@ const sensorPropertiesMap = { }, 'signal': { reading: ["signaldBm", xforms.noop] + }, + 'batteryremaining': { + reading: ["batteryRemaining", xforms.noop] } }; /* eslint-enable no-invalid-this */ diff --git a/lib/tag.js b/lib/tag.js index 3fdb216..a4f5c38 100644 --- a/lib/tag.js +++ b/lib/tag.js @@ -302,6 +302,13 @@ WirelessTag.prototype.hasBatterySensor = function() { WirelessTag.prototype.hasSignalSensor = function() { return this.isPhysicalTag(); }; +/** + * Whether the tag reports the batteryRemaining. (All + * non-virtual tags do.) + */ + WirelessTag.prototype.hasBatteryRemainingSensor = function() { + return this.isPhysicalTag(); +}; /** Whether the tag's motion sensor is an accelerometer. */ WirelessTag.prototype.hasAccelerometer = function() { return this.hasMotionSensor() && ((this.rev & 0x0F) === 0x0A); From d2def18c42e2cd1f73db1a3950e52eb08cd728cd Mon Sep 17 00:00:00 2001 From: Peter Aquino Date: Mon, 8 Nov 2021 11:32:35 -0800 Subject: [PATCH 3/3] Added light sensor capabilities to tag type 107 --- lib/tag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tag.js b/lib/tag.js index a4f5c38..44efcd3 100644 --- a/lib/tag.js +++ b/lib/tag.js @@ -212,7 +212,7 @@ WirelessTag.prototype.hasMotionSensor = function() { }; /** Whether the tag has a light sensor. */ WirelessTag.prototype.hasLightSensor = function() { - return (this.tagType === 26); + return (this.tagType === 26 || this.tagType === 107); }; /** Whether the tag has a moisture sensor. */ WirelessTag.prototype.hasMoistureSensor = function() {