Skip to content

Commit

Permalink
Update waterdetector.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Sep 11, 2024
1 parent 50edae9 commit fe7fb89
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/device/waterdetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ export class WaterDetector extends deviceBase {
await this.debugLog(`(state, status, battery) = BLE: (${this.serviceData.state}, ${this.serviceData.status}, ${this.serviceData.battery}), current:(${this.LeakSensor?.LeakDetected}, ${this.Battery.BatteryLevel})`)

// LeakSensor
if (this.device.waterdetector?.hide_leak && this.LeakSensor?.Service) {
if (!this.device.waterdetector?.hide_leak && this.LeakSensor?.Service) {
// StatusActive
this.LeakSensor.StatusActive = this.serviceData.state
await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`)

// LeakDetected
if (this.device.waterdetector.dry) {
if (this.device.waterdetector?.dry) {
this.LeakSensor.LeakDetected = this.serviceData.status === 0 ? 1 : 0
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
} else {
Expand Down Expand Up @@ -186,8 +186,13 @@ export class WaterDetector extends deviceBase {
await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`)

// LeakDetected
this.LeakSensor.LeakDetected = this.deviceStatus.status
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
if (this.device.waterdetector?.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}`)
}
}

// BatteryLevel
Expand Down Expand Up @@ -227,8 +232,13 @@ export class WaterDetector extends deviceBase {
await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`)

// LeakDetected
this.LeakSensor.LeakDetected = this.webhookContext.detectionState
await this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
if (this.device.waterdetector?.dry) {
this.LeakSensor.LeakDetected = this.webhookContext.detectionState === 0 ? 1 : 0
this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
} else {
this.LeakSensor.LeakDetected = this.webhookContext.detectionState
await this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
}
}

// BatteryLevel
Expand Down

0 comments on commit fe7fb89

Please sign in to comment.