Fix BLE deep-sleep restore using minutes math instead of hours - #69
Fix BLE deep-sleep restore using minutes math instead of hours#69bharvey88 wants to merge 2 commits into
Conversation
TEMP-1B_BLE.yaml packages Battery.yaml, whose "Sleep Duration" number is in hours (unit_of_measurement "h", initial 12, deep_sleep default 12h). Its on_boot restore lambda multiplied the stored value by 60 * 1000 (minutes to ms), so after every reboot the device slept 60x too short, waking roughly every 12 minutes instead of 12 hours and draining the battery. Change the expression to * 60 * 60 * 1000 (hours to ms), matching the correct math already used in TEMP-1B.yaml, TEMP-1B_Minimal.yaml, and Battery.yaml's own on_value handler. The non-battery variants keep * 60 * 1000 because NonBattery.yaml's Sleep Duration is in minutes. Sibling of the same bug found in AIR-1 during the 26.7.23.1 release (ApolloAutomation/AIR-1#119). Bumps version to 26.7.24.1. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe ESPHome boot lambda now interprets the configured deep sleep duration in hours instead of minutes by converting it to milliseconds with an additional factor of 60. ChangesDeep Sleep Duration
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to The change corrects BLE deep-sleep restoration from minutes-based to hours-based calculation for battery devices, preventing unnecessarily frequent wakeups. No actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Conflicts were confined to `version` and `min_version`. Kept this branch's content and took beta's newer values on both keys; `channel_colors` requires ESPHome 2026.8.0. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Version: 26.7.24.1
What does this implement/fix?
TEMP-1B_BLE.yamlpackagesBattery.yaml, whose "Sleep Duration" number is in hours (unit_of_measurement: "h",initial_value: 12, and thedeep_sleepdefault is12h). Theon_bootdeep-sleep restore lambda multiplied the stored value by60 * 1000(minutes to ms) instead of60 * 60 * 1000(hours to ms).The result: after every reboot the device restored a sleep duration 60x too short, waking roughly every 12 minutes instead of every 12 hours and draining the battery.
The fix changes the expression to
* 60 * 60 * 1000, matching the correct math already used inTEMP-1B.yaml,TEMP-1B_Minimal.yaml, andBattery.yaml's ownon_valuehandler. The non-battery variants (TEMP-1.yaml,TEMP-1_BLE.yaml,TEMP-1_Minimal.yaml) correctly keep* 60 * 1000becauseNonBattery.yaml's Sleep Duration is in minutes.TEMP-1B_BLE_R2.yamlincludesTEMP-1B_BLE.yaml, so it inherits the fix.This is a sibling of the same hours-vs-minutes bug found in AIR-1 during the 26.7.23.1 release (ApolloAutomation/AIR-1#119).
Validated with
esphome configon TEMP-1B_BLE.yaml, TEMP-1B.yaml, and TEMP-1B_BLE_R2.yaml: all report "Configuration is valid!".Types of changes
Checklist / Checklijst:
If user-visible functionality or configuration variables are added/modified:
🤖 Generated with Claude Code
Summary by CodeRabbit