-
-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Some BLE devices require specific connection parameters (interval, latency, supervision timeout) to behave reliably—for example faster notifications, reduced lag, or more stable presence detection. BlueZ does support updating these parameters via the Linux kernel’s HCI Management (MGMT) interface, which tools like btmgmt already use.
Bleak, however, has confirmed that bypassing the D-Bus/bluetoothd layer to call MGMT directly is out of scope for the library (hbldh/bleak#1446). BlueZ currently exposes no D-Bus API for connection parameter updates, so Bleak cannot support this feature natively. This opens a possibility for Home Assistant’s Bluetooth stack to provide this functionality instead.
Problem Statement
Certain integrations (e.g., locks, sensors, high-frequency notification devices, presence detectors) benefit significantly from tuning BLE connection parameters. Without this, Home Assistant may experience:
- Slow notification delivery
- Higher latency on characteristic subscriptions
- Less responsive device interaction
- Suboptimal power/performance trade-offs depending on device type
Home Assistant currently relies entirely on Bleak for BLE interactions, and Bleak cannot expose connection parameter control because of its cross-platform API constraints.
Proposed Solution
Introduce an optional, Linux-only connection parameter manager inside habluetooth that:
- Applies BLE connection parameters using the kernel MGMT API
- Opens the MGMT socket
- Sends “Set Connection Parameters” for the active connection
- Mirrors how btmgmt handles this
- Degrades to no-op if permissions (e.g., CAP_NET_ADMIN) are not available
- Supports predefined “policies”
Example:- fastest_response
- responsive
- balanced
- slow_updates
- lowest_power
These map to specific interval/latency/timeout combinations for clarity.
- Integrates with existing HA Bluetooth connection flow
- Apply policy immediately after establishing a BLE connection
- Log results for debugging
- No changes required in Bleak itself
- Platform behavior
- Linux (HA OS / Supervisor / containers): Full MGMT support
- macOS / Windows: Graceful no-op
- Keeps HA cross-platform consistent while enabling an optional enhancement where supported
If this proposal aligns with HA’s direction, I’m happy to prepare an initial PR or RFC-style design.