From c07a96e63c77f956dad964d6b7b29f9066a4876d Mon Sep 17 00:00:00 2001 From: Sieren Date: Sat, 11 Sep 2021 10:16:10 +0200 Subject: [PATCH] fixup! Add Aqara TVOC Sensor Support with history --- lib/HueSensor.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/HueSensor.js b/lib/HueSensor.js index 5338945..a8a1ebc 100644 --- a/lib/HueSensor.js +++ b/lib/HueSensor.js @@ -1567,6 +1567,7 @@ function HueSensor (accessory, id, obj) { this.history.entry.temp = 0 this.history.entry.humidity = 0 this.history.entry.voc = 0 + break default: break } @@ -1801,6 +1802,7 @@ HueSensor.prototype.checkState = function (state, event) { switch (key) { case 'airquality': this.checkAirQuality(state.airquality) + break case 'angle': break case 'battery': @@ -2047,8 +2049,9 @@ HueSensor.prototype.addEntry = function (changed) { break case 'room2': { - let key = this.type.key === 'airqualityppb' ? 'voc' : - (this.type.key === 'temperature' ? 'temp' : this.type.key) + const key = this.type.key === 'airqualityppb' + ? 'voc' + : (this.type.key === 'temperature' ? 'temp' : this.type.key) this.history.entry[key] = this.hk[this.type.key] if (changed || this.type.key !== this.history.resource.type.key) { return @@ -2407,17 +2410,18 @@ HueSensor.prototype.checkAirQuality = function (airquality) { ) this.obj.state.airquality = airquality } - let qualities = { - 'excellent': Characteristic.AirQuality.EXCELLENT, - 'good': Characteristic.AirQuality.GOOD, - 'moderate': Characteristic.AirQuality.FAIR, - 'poor': Characteristic.AirQuality.INFERIOR, - 'unhealthy': Characteristic.AirQuality.POOR + const qualities = { + excellent: Characteristic.AirQuality.EXCELLENT, + good: Characteristic.AirQuality.GOOD, + moderate: Characteristic.AirQuality.FAIR, + poor: Characteristic.AirQuality.INFERIOR, + unhealthy: Characteristic.AirQuality.POOR } - + let hkAirQuality = qualities[airquality] - if (!hkAirQuality) + if (!hkAirQuality) { hkAirQuality = Characteristic.AirQuality.UNKNOWN + } if (this.hk.airquality !== hkAirQuality) { if (this.hk.airquality !== undefined) {