Skip to content

Fix BLE deep-sleep restore using minutes math instead of hours#69

Open
bharvey88 wants to merge 1 commit into
betafrom
fix/ble-sleep-hours
Open

Fix BLE deep-sleep restore using minutes math instead of hours#69
bharvey88 wants to merge 1 commit into
betafrom
fix/ble-sleep-hours

Conversation

@bharvey88

Copy link
Copy Markdown
Contributor

Version: 26.7.24.1

What does this implement/fix?

TEMP-1B_BLE.yaml packages Battery.yaml, whose "Sleep Duration" number is in hours (unit_of_measurement: "h", initial_value: 12, and the deep_sleep default is 12h). The on_boot deep-sleep restore lambda multiplied the stored value by 60 * 1000 (minutes to ms) instead of 60 * 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 in TEMP-1B.yaml, TEMP-1B_Minimal.yaml, and Battery.yaml's own on_value handler. The non-battery variants (TEMP-1.yaml, TEMP-1_BLE.yaml, TEMP-1_Minimal.yaml) correctly keep * 60 * 1000 because NonBattery.yaml's Sleep Duration is in minutes. TEMP-1B_BLE_R2.yaml includes TEMP-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 config on TEMP-1B_BLE.yaml, TEMP-1B.yaml, and TEMP-1B_BLE_R2.yaml: all report "Configuration is valid!".

Types of changes

  • Bugfix (fixed change that fixes an issue)
  • New feature (thanks!)
  • Breaking change (repair/feature that breaks existing functionality)
  • Dependency Update - Does not publish
  • Other - Does not publish
  • Website of github readme file update - Does not publish
  • Github workflows - Does not publish

Checklist / Checklijst:

  • The code change has been tested and works locally
  • The code change has not yet been tested

If user-visible functionality or configuration variables are added/modified:

  • Added/updated documentation for the web page

🤖 Generated with Claude Code

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)
@bharvey88 bharvey88 added the bugfix Bug fix label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@bharvey88, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b719866-2cd7-4ffa-8bf4-f4b17ac49e17

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4189d and 2cc4cca.

📒 Files selected for processing (2)
  • Integrations/ESPHome/Core.yaml
  • Integrations/ESPHome/TEMP-1B_BLE.yaml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ble-sleep-hours

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant