From 50edae91e156e1bf8916ff5b5a6603617863b7a8 Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Tue, 10 Sep 2024 22:40:55 -0500 Subject: [PATCH] Add Water Detector Dry Alert --- config.schema.json | 9 +++++++++ src/device/waterdetector.ts | 9 +++++++-- src/settings.ts | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config.schema.json b/config.schema.json index 0e2319a6..50dfd1f3 100644 --- a/config.schema.json +++ b/config.schema.json @@ -593,6 +593,14 @@ "condition": { "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Water Detector' && model.options.devices[arrayIndices].deviceId);" } + }, + "dry": { + "title": "Water Detector's Dry Alert", + "type": "boolean", + "description": "If true, the Water Detector will send an alert when it is dry.", + "condition": { + "functionBody": "return (model.options && model.options.devices && !model.options.devices[arrayIndices].hide_device && model.options.devices[arrayIndices].configDeviceType === 'Water Detector' && model.options.devices[arrayIndices].deviceId);" + } } } }, @@ -1862,6 +1870,7 @@ "options.devices[].hub.hide_humidity", "options.devices[].hub.hide_lightsensor", "options.devices[].waterdetector.hide_leak", + "options.devices[].waterdetector.dry", "options.devices[].humidifier.set_minStep", "options.devices[].humidifier.hide_temperature", "options.devices[].curtain.set_minStep", diff --git a/src/device/waterdetector.ts b/src/device/waterdetector.ts index 44929874..d2f7e911 100644 --- a/src/device/waterdetector.ts +++ b/src/device/waterdetector.ts @@ -157,8 +157,13 @@ export class WaterDetector extends deviceBase { await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`) // LeakDetected - this.LeakSensor.LeakDetected = this.serviceData.status - this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) + if (this.device.waterdetector.dry) { + this.LeakSensor.LeakDetected = this.serviceData.status === 0 ? 1 : 0 + this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) + } else { + this.LeakSensor.LeakDetected = this.serviceData.status + this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`) + } } // BatteryLevel this.Battery.BatteryLevel = this.serviceData.battery diff --git a/src/settings.ts b/src/settings.ts index b47ee226..a42172ef 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -185,6 +185,7 @@ interface motion { interface waterdetector { hide_leak?: boolean + dry?: boolean }; interface colorbulb {