Skip to content

Commit

Permalink
Add Water Detector Dry Alert
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Sep 11, 2024
1 parent a8f3cb6 commit 50edae9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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);"
}
}
}
},
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions src/device/waterdetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ interface motion {

interface waterdetector {
hide_leak?: boolean
dry?: boolean
};

interface colorbulb {
Expand Down

0 comments on commit 50edae9

Please sign in to comment.