fix: restore Battery service for water detector#1387
Merged
donavanbecker merged 2 commits intoJul 1, 2026
Merged
Conversation
The v5.0.0 rewrite (OpenWonderLabs#1357) replaced the dedicated per-device files with a single declarative genericDevice.ts. In that rewrite, only the primary service for each device was re-wired. The Water Detector's Battery service from v4 was dropped. The SwitchBot Water Leak Detector reports battery via the OpenAPI 'battery' state field, so HomeKit low-battery alerts are useful and were expected behavior in v4. Restores BatteryLevel, StatusLowBattery (threshold <20%), and ChargingState (not chargeable) characteristics on the LeakSensor accessory.
Contributor
|
need to resolve conflicts |
…or-battery-service # Conflicts: # src/devices/genericDevice.ts
Contributor
Author
|
@donavanbecker this is mergeable now! Thank you so much for merging #1386 🙇 |
Contributor
Author
|
🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
♻️ Current situation
The v5.0.0 rewrite (#1357) replaced the dedicated per-device files with a single declarative genericDevice.ts. In that rewrite, only the primary service for each device was re-wired. The Water Detector's Battery service from v4 was dropped.
The SwitchBot Water Leak Detector reports battery via the OpenAPI 'battery' state field, so HomeKit low-battery alerts are useful and were expected behavior in v4.
💡 Proposed solution
Restores BatteryLevel, StatusLowBattery (threshold <20%), and ChargingState (not chargeable) characteristics on the LeakSensor accessory.
Also avoids Homebridge slow-read warnings for the Battery characteristics by caching the battery level and returning it synchronously from
BatteryLevel/StatusLowBattery.The cache is warmed from the SwitchBot OpenAPI status endpoint during device init and refreshed in the background, so HomeKit reads do not block on a live API call.
⚙️ Release Notes
fix(battery-regression): restore Battery service for leak sensor➕ Additional Information
n/a
Testing
Reviewer Nudging
review the battery fetching logic