diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc65385..d90ea57e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/) +## [4.1.3](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v4.1.3) (2024-11-05) + +### What's Changed +- Fix characteristic warnings [#1104](https://github.com/OpenWonderLabs/homebridge-switchbot/pull/1104), Thanks [@dnicolson](https://github.com/dnicolson) + +**Full Changelog**: https://github.com/OpenWonderLabs/homebridge-switchbot/compare/v4.1.2...v4.1.3 + ## [4.1.2](https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v4.1.2) (2024-11-04) ### What's Changed diff --git a/README.md b/README.md index c12ed480..715f07d3 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ - [SwitchBot Battery Circulator Fan](https://us.switch-bot.com/products/switchbot-battery-circulator-fan) - Supports OpenAPI Connection Only - [SwitchBot Water Leak Detector](https://us.switch-bot.com/products/switchbot-water-leak-detector) - - Supports OpenAPI Connection Only + - Supports OpenAPI & Bluetooth Low Energy (BLE) Connections ## Supported IR Devices @@ -216,9 +216,9 @@ ## SwitchBot APIs -- [OpenWonderLabs/SwitchBotAPI](https://github.com/OpenWonderLabs/SwitchBotAPI) -- [OpenWonderLabs/SwitchBotAPI-BLE](https://github.com/OpenWonderLabs/SwitchBotAPI-BLE) - - [OpenWonderLabs/node-switchbot](https://github.com/OpenWonderLabs/node-switchbot) +- [OpenWonderLabs/node-switchbot](https://github.com/OpenWonderLabs/node-switchbot) + - [OpenWonderLabs/SwitchBotAPI](https://github.com/OpenWonderLabs/SwitchBotAPI) + - [OpenWonderLabs/SwitchBotAPI-BLE](https://github.com/OpenWonderLabs/SwitchBotAPI-BLE) ## Community diff --git a/docs/functions/default.html b/docs/functions/default.html index f1036e70..41bb509b 100644 --- a/docs/functions/default.html +++ b/docs/functions/default.html @@ -1 +1 @@ -default | @switchbot/homebridge-switchbot
  • Parameters

    • api: API

    Returns void

+default | @switchbot/homebridge-switchbot
  • Parameters

    • api: API

    Returns void

diff --git a/docs/index.html b/docs/index.html index d097fbf7..b25ba6f5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -278,7 +278,7 @@
  • SwitchBot Water Leak Detector
  • @@ -364,10 +364,10 @@ diff --git a/package-lock.json b/package-lock.json index ec454ffd..ec400f32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@switchbot/homebridge-switchbot", - "version": "4.1.2", + "version": "4.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@switchbot/homebridge-switchbot", - "version": "4.1.2", + "version": "4.1.3", "funding": [ { "type": "Paypal", diff --git a/package.json b/package.json index d66588e2..bf37cba2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@switchbot/homebridge-switchbot", "displayName": "SwitchBot", "type": "module", - "version": "4.1.2", + "version": "4.1.3", "description": "The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.", "author": "SwitchBot (https://github.com/SwitchBot)", "contributors": [ diff --git a/src/device/blindtilt.ts b/src/device/blindtilt.ts index 6b793039..8f19621f 100644 --- a/src/device/blindtilt.ts +++ b/src/device/blindtilt.ts @@ -350,12 +350,11 @@ export class BlindTilt extends deviceBase { this.getLightLevel(this.serviceData.lightLevel, set_minLux, set_maxLux, spaceBetweenLevels) this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`) } - - // BatteryLevel - if (this.serviceData?.battery) { + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel this.Battery.BatteryLevel = this.serviceData.battery this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - // StatusLowBattery this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW diff --git a/src/device/bot.ts b/src/device/bot.ts index 7c5b5470..7617d22e 100644 --- a/src/device/bot.ts +++ b/src/device/bot.ts @@ -281,16 +281,17 @@ export class Bot extends deviceBase { const mode = this.serviceData.mode ? 'Switch' : 'Press' this.debugLog(`${mode} Mode, On: ${this.On}`) this.accessory.context.On = this.On - - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } /** diff --git a/src/device/contact.ts b/src/device/contact.ts index d2bb917c..86b8ce4d 100644 --- a/src/device/contact.ts +++ b/src/device/contact.ts @@ -204,14 +204,17 @@ export class Contact extends deviceBase { this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2) this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`) } - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { diff --git a/src/device/curtain.ts b/src/device/curtain.ts index 27700c7f..e136b61e 100644 --- a/src/device/curtain.ts +++ b/src/device/curtain.ts @@ -391,14 +391,17 @@ export class Curtain extends deviceBase { this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 19) this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`) } - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { diff --git a/src/device/iosensor.ts b/src/device/iosensor.ts index fe8f6b45..0a7b68ef 100644 --- a/src/device/iosensor.ts +++ b/src/device/iosensor.ts @@ -178,23 +178,22 @@ export class IOSensor extends deviceBase { async BLEparseStatus(): Promise { this.debugLog('BLEparseStatus') this.debugLog(`(battery, temperature, humidity) = BLE:(${this.serviceData.battery}, ${this.serviceData.celsius}, ${this.serviceData.humidity}), current:(${this.Battery.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`) - - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) - + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } // CurrentRelativeHumidity if (!(this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) { this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100) this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`) } - // Current Temperature if (!(this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) { const CELSIUS = this.serviceData.celsius < 0 ? 0 : this.serviceData.celsius > 100 ? 100 : this.serviceData.celsius diff --git a/src/device/lock.ts b/src/device/lock.ts index 46916bea..dc67a47f 100644 --- a/src/device/lock.ts +++ b/src/device/lock.ts @@ -224,16 +224,17 @@ export class Lock extends deviceBase { : this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED this.debugLog(`ContactSensorState: ${this.ContactSensor.ContactSensorState}`) } - - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { diff --git a/src/device/meter.ts b/src/device/meter.ts index 4ef5b04d..ee1f3913 100644 --- a/src/device/meter.ts +++ b/src/device/meter.ts @@ -184,16 +184,17 @@ export class Meter extends deviceBase { this.TemperatureSensor.CurrentTemperature = CELSIUS this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`) } - - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { diff --git a/src/device/meterplus.ts b/src/device/meterplus.ts index c5a99832..17b608db 100644 --- a/src/device/meterplus.ts +++ b/src/device/meterplus.ts @@ -188,14 +188,17 @@ export class MeterPlus extends deviceBase { this.TemperatureSensor.CurrentTemperature = CELSIUS this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`) } - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { diff --git a/src/device/meterpro.ts b/src/device/meterpro.ts index 19f08015..8b56fbc5 100644 --- a/src/device/meterpro.ts +++ b/src/device/meterpro.ts @@ -188,14 +188,17 @@ export class MeterPro extends deviceBase { this.TemperatureSensor.CurrentTemperature = CELSIUS this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`) } - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { diff --git a/src/device/motion.ts b/src/device/motion.ts index e100a092..35967230 100644 --- a/src/device/motion.ts +++ b/src/device/motion.ts @@ -171,16 +171,17 @@ export class Motion extends deviceBase { this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2) this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`) } - - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { diff --git a/src/device/robotvacuumcleaner.ts b/src/device/robotvacuumcleaner.ts index 30b2910f..e7fd3fa2 100644 --- a/src/device/robotvacuumcleaner.ts +++ b/src/device/robotvacuumcleaner.ts @@ -170,15 +170,17 @@ export class RobotVacuumCleaner extends deviceBase { this.LightBulb.On = !!['InDustCollecting', 'Clearing'].includes(this.deviceStatus.workingStatus) this.debugLog(`On: ${this.LightBulb.On}`) - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - - // StatusLowBattery - this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 + ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW + : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus() { diff --git a/src/device/waterdetector.ts b/src/device/waterdetector.ts index 8ddb0e95..9983c194 100644 --- a/src/device/waterdetector.ts +++ b/src/device/waterdetector.ts @@ -106,9 +106,7 @@ export class WaterDetector extends deviceBase { accessory.context.LeakSensor = this.LeakSensor as object // Initialize LeakSensor Characteristic - this.LeakSensor!.Service.setCharacteristic(this.hap.Characteristic.Name, this.LeakSensor.Name).setCharacteristic(this.hap.Characteristic.StatusActive, true).getCharacteristic(this.hap.Characteristic.LeakDetected).onGet(() => { - return this.LeakSensor!.LeakDetected - }) + this.LeakSensor.Service.setCharacteristic(this.hap.Characteristic.Name, this.LeakSensor.Name).setCharacteristic(this.hap.Characteristic.StatusActive, true) } // Retrieve initial values and updateHomekit @@ -151,25 +149,26 @@ export class WaterDetector extends deviceBase { // LeakSensor if (!(this.device as waterDetectorConfig).hide_leak && this.LeakSensor?.Service) { // StatusActive - this.LeakSensor.StatusActive = this.serviceData.leak + this.LeakSensor.StatusActive = this.serviceData.tampered this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`) // LeakDetected this.LeakSensor.LeakDetected = (this.device as waterDetectorConfig).dry - ? this.serviceData.tampered ? 1 : 0 - : this.serviceData.tampered + ? !this.serviceData.leak ? this.hap.Characteristic.LeakDetected.LEAK_DETECTED : this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED + : this.serviceData.leak ? this.hap.Characteristic.LeakDetected.LEAK_DETECTED : this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) } - // BatteryLevel - this.Battery.BatteryLevel = this.serviceData.battery - this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) - // StatusLowBattery - this.Battery.StatusLowBattery = this.serviceData.low_battery - ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW - : this.Battery.BatteryLevel < 10 + // Battery Info + if (this.serviceData.battery) { + // BatteryLevel + this.Battery.BatteryLevel = this.serviceData.battery + this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`) + // StatusLowBattery + this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10 ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL - this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`) + } } async openAPIparseStatus(): Promise { @@ -183,13 +182,10 @@ export class WaterDetector extends deviceBase { this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`) // LeakDetected - if ((this.device as waterDetectorConfig).dry) { - this.LeakSensor.LeakDetected = this.deviceStatus.status === 0 ? 1 : 0 - this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) - } else { - this.LeakSensor.LeakDetected = this.deviceStatus.status - this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) - } + this.LeakSensor.LeakDetected = (this.device as waterDetectorConfig).dry + ? this.deviceStatus.status === 0 ? this.hap.Characteristic.LeakDetected.LEAK_DETECTED : this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED + : this.deviceStatus.status === 1 ? this.hap.Characteristic.LeakDetected.LEAK_DETECTED : this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED + this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) } // BatteryLevel @@ -229,13 +225,10 @@ export class WaterDetector extends deviceBase { this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`) // LeakDetected - if ((this.device as waterDetectorConfig).dry) { - this.LeakSensor.LeakDetected = this.webhookContext.detectionState === 0 ? 1 : 0 - this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) - } else { - this.LeakSensor.LeakDetected = this.webhookContext.detectionState - this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) - } + this.LeakSensor.LeakDetected = (this.device as waterDetectorConfig).dry + ? this.webhookContext.detectionState === 0 ? this.hap.Characteristic.LeakDetected.LEAK_DETECTED : this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED + : this.webhookContext.detectionState === 1 ? this.hap.Characteristic.LeakDetected.LEAK_DETECTED : this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED + this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) } // BatteryLevel