Skip to content

Unify BLE into one firmware: runtime Bluetooth Proxy switch + channel-only OTA#100

Merged
bharvey88 merged 1 commit into
betafrom
unified/ble-switch
Jul 9, 2026
Merged

Unify BLE into one firmware: runtime Bluetooth Proxy switch + channel-only OTA#100
bharvey88 merged 1 commit into
betafrom
unified/ble-switch

Conversation

@bharvey88

@bharvey88 bharvey88 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Version: 26.7.9.1 (no change — part of the single release)

What does this implement/fix?

Collapses the build-time _BLE variant into one firmware where Bluetooth and the update channel are runtime controls, and rips out the fragile manifest-matching machinery (the CodeRabbit-flagged OTA re-enable bug goes with it).

  • bluetooth_proxy + esp32_ble_tracker compiled into Core.yaml — every variant inherits it. Measured flash: base 94.1%, Factory 95.4% (both fit the 4MB app partition).
  • New "Bluetooth Proxy" switch (default OFF, persisted): onesp32_ble_tracker.start_scan, offstop_scan. The esp32_ble stack stays up so esp32_improv provisioning still works on Factory.
  • Removed the firmware_ble manifest selector. apply_ota_source is now channel-only (Stable/Beta) with per-variant manifest bases — legacy MSR-1_BLE.yaml keeps its firmware-ble manifest via substitution overrides.
  • Simplified the Firmware Update flow: drop the BLE stack for the TLS download, restore it + the switch's scan state on the not-started path, reboot restores the switch. No more unconditional re-enable.
  • MSR-1_BLE.yaml: dropped its now-inherited bluetooth_proxy; added the manifest substitutions.

Follow-ups (not in this PR): retire beta-channel/ configs, reconcile the publish pipeline, remove the now-vestigial ble_firmware substitution.

Note for the reviewer: the exact esp32_ble_tracker.start_scan/stop_scan action form (with/without a tracker id:) is confirmed at compile — CI is the check.

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

Summary by CodeRabbit

  • New Features

    • Added a dedicated Bluetooth Proxy control for starting and stopping Bluetooth scanning more directly.
    • Improved firmware update handling to better support stable and beta update paths.
  • Bug Fixes

    • Firmware updates now restore Bluetooth scanning automatically after the update process.
    • Simplified update selection to reduce mismatches between the chosen firmware channel and the update source.

…-only OTA

Replaces the build-time BLE variant machinery with runtime toggles:
- Compile bluetooth_proxy + esp32_ble_tracker into Core.yaml so every variant
  inherits it (base ~94.1% flash, Factory ~95.4% - both fit 4MB).
- Add a "Bluetooth Proxy" switch (default off) that starts/stops scanning via
  esp32_ble_tracker; the esp32_ble stack stays up so esp32_improv keeps working
  on the Factory image.
- Remove the firmware_ble manifest selector. apply_ota_source is now
  channel-only, using per-variant manifest bases (ota_stable_manifest /
  ota_beta_manifest) so legacy MSR-1_BLE devices keep their firmware-ble manifest.
- Delete the manifest-matching guard and simplify the Firmware Update flow:
  drop the BLE stack for the TLS download, restore it + the switch's scan state
  on the not-started path, and let the post-update reboot restore the switch.
  This also fixes the unconditional BLE re-enable CodeRabbit flagged.
- MSR-1_BLE.yaml: drop its now-inherited bluetooth_proxy; add the manifest subs.

Part of the single 26.7.9.1 release; no version bump.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9bec9840-4a1f-4878-8769-76dbd24dbfca

📥 Commits

Reviewing files that changed from the base of the PR and between 9134ab2 and a6d9f2a.

📒 Files selected for processing (2)
  • Integrations/ESPHome/Core.yaml
  • Integrations/ESPHome/MSR-1_BLE.yaml

Walkthrough

The ESPHome Core configuration replaces variant-based BLE/OTA selection with per-channel manifest substitutions (ota_stable_manifest, ota_beta_manifest) and a new template switch (bluetooth_proxy_switch) controlling BLE scanning. The Firmware Update flow and apply_ota_source script are simplified accordingly, removing manifest/channel mismatch validation. MSR-1_BLE.yaml adds legacy manifest substitutions and drops bluetooth_proxy active setting.

Changes

OTA manifest and Bluetooth proxy switch refactor

Layer / File(s) Summary
Bluetooth Proxy switch and boot wiring
Integrations/ESPHome/Core.yaml
Adds a template switch bluetooth_proxy_switch with on_turn_on/off scan control, and updates on_boot to run apply_ota_source then set BLE scan state from the switch's persisted state.
Firmware update button and OTA source script
Integrations/ESPHome/Core.yaml
Reworks the Firmware Update button to disable/enable BLE around the OTA call, invoke apply_ota_source and update_http_request.perform(true) directly (removing manifest/channel/variant validation), and restore BLE scan state afterward; simplifies apply_ota_source to pick between ota_stable_manifest and ota_beta_manifest based solely on firmware_channel.
MSR-1 BLE legacy manifest substitutions
Integrations/ESPHome/MSR-1_BLE.yaml
Adds ota_stable_manifest/ota_beta_manifest substitution variables for legacy BLE manifests and removes the bluetooth_proxy: active: true section.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • ApolloAutomation/MSR-1#89: Introduces the Stable/Beta firmware channel selector and OTA manifest script/button logic that this PR directly refactors.
  • ApolloAutomation/MSR-1#90: Also modifies apply_ota_source around a BLE/proxy selector (firmware_ble vs bluetooth_proxy_switch) and related boot/update automations.
  • ApolloAutomation/MSR-1#93: Modifies the same Firmware Update button logic around manifest validation, which this PR removes and rewrites.

Poem

A switch, a hop, a manifest sung,
No more variant tangles among!
Stable or Beta, the choice is plain,
Scan on, scan off, then scan again 🐇
Hop the update, no mismatch fright—
This bunny's firmware feels just right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: consolidating BLE behavior into one firmware with a runtime Bluetooth Proxy switch and channel-only OTA.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch unified/ble-switch

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant