Skip to content

Add conditional to Single Core Fix sample code#6650

Merged
jesserockz merged 6 commits into
esphome:currentfrom
DukeSniper:patch-1
Jun 8, 2026
Merged

Add conditional to Single Core Fix sample code#6650
jesserockz merged 6 commits into
esphome:currentfrom
DukeSniper:patch-1

Conversation

@DukeSniper

Copy link
Copy Markdown
Contributor

Do not stop BLE scanning on disconnect if there are still active API connections, only stop when all connections are lost

Description

Current Example code stops scanning on any API disconnect. If both HA and a logging client connect and the logger disconnects, the scanning stops, even tho HA is still connected.

Checklist

  • I am merging into next because this is new documentation that has a matching pull-request in esphome as linked above.
    or

  • I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • Link added in /src/content/docs/components/index.mdx when creating new documents for new components or cookbook.

Do not stop BLE scanning on disconnect if there are still active API connections, only stop when all connections are lost
@esphome esphome Bot added the current label May 18, 2026
@netlify

netlify Bot commented May 18, 2026

Copy link
Copy Markdown

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit 0c0708c
🔍 Latest deploy log https://app.netlify.com/projects/esphome/deploys/6a1d3d82e3b77a0008fecdb7
😎 Deploy Preview https://deploy-preview-6650--esphome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

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: 3695e9ab-f8f9-44b3-959a-ae1820f5f37a

📥 Commits

Reviewing files that changed from the base of the PR and between ff04260 and 35ca71b.

📒 Files selected for processing (1)
  • src/content/docs/components/esp32_ble_tracker.mdx
✅ Files skipped from review due to trivial changes (1)
  • src/content/docs/components/esp32_ble_tracker.mdx

Walkthrough

The docs example for single-core ESP32 now stops BLE scanning on api.on_client_disconnected only when api.connected is false, preventing unconditional scan stops while the API remains connected.

Changes

Single-core chip example correction

Layer / File(s) Summary
Single-core chip example configuration fix
src/content/docs/components/esp32_ble_tracker.mdx
The esp32_ble_tracker.stop_scan action is now wrapped in an if condition that checks not: api.connected, ensuring the scan is stopped only when the API is truly disconnected rather than unconditionally on client disconnection.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a conditional guard to the Single Core Fix example code to prevent unconditional BLE scan stopping.
Description check ✅ Passed The description clearly explains the problem being fixed and how the change addresses the issue of premature BLE scan stopping when multiple API clients are connected.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/content/docs/components/esp32_ble_tracker.mdx`:
- Around line 289-294: Add a leading dash before the if action so it matches the
action list syntax used elsewhere; specifically, change the action entry that
currently starts with "if:" (the block that tests "not: api.connected" and then
runs "esp32_ble_tracker.stop_scan") to be prefixed with "- if:" so the
conditional is treated as an item in the trigger's action list.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4349431-4d2e-4914-af7f-2a86910ed042

📥 Commits

Reviewing files that changed from the base of the PR and between abee6ab and ff04260.

📒 Files selected for processing (1)
  • src/content/docs/components/esp32_ble_tracker.mdx

Comment thread src/content/docs/components/esp32_ble_tracker.mdx Outdated
@jesserockz jesserockz merged commit 44339b1 into esphome:current Jun 8, 2026
6 checks passed
@DukeSniper DukeSniper deleted the patch-1 branch June 8, 2026 05:54
bughaver pushed a commit to bughaver/esphome.io that referenced this pull request Jun 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants