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 69db1a8..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() { @@ -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() { @@ -296,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); @@ -331,6 +344,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 +403,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); };