From 91241d13904a130e17719b6dd1ee48c801414220 Mon Sep 17 00:00:00 2001 From: Sieren Date: Sat, 11 Sep 2021 10:06:05 +0200 Subject: [PATCH] fixup! Add Aqara TVOC Sensor Support with history --- lib/HueSensor.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/HueSensor.js b/lib/HueSensor.js index d83614b..8c1e9eb 100644 --- a/lib/HueSensor.js +++ b/lib/HueSensor.js @@ -2405,20 +2405,18 @@ HueSensor.prototype.checkAirQuality = function (airquality) { ) this.obj.state.airquality = airquality } - var hkAirQuality; - if (airquality == 'excellent') { - hkAirQuality = Characteristic.AirQuality.EXCELLENT - } else if (airquality == 'good') { - hkAirQuality = Characteristic.AirQuality.GOOD - } else if (airquality == 'moderate') { - hkAirQuality = Characteristic.AirQuality.FAIR - } else if (airquality == 'poor') { - hkAirQuality = Characteristic.AirQuality.INFERIOR - } else if (airquality == 'unhealthy') { - hkAirQuality = Characteristic.AirQuality.POOR - } else { + let 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) hkAirQuality = Characteristic.AirQuality.UNKNOWN - } + if (this.hk.airquality !== hkAirQuality) { if (this.hk.airquality !== undefined) { this.log.info(