Home Assistant Bluetooth provides Python models and helpers for integrating Bluetooth devices with Home Assistant. It acts as a wrapper around the `habluetooth` library to offer a consistent API. The current version is 2.0.0, and it follows a release cadence tied to Home Assistant development and dependency updates.
pip install home-assistant-bluetoothVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `BluetoothManager` and register a callback to receive Bluetooth advertisement data. It will continuously listen for advertisements until interrupted.
Ensure your environment and the `habluetooth` dependency (and thus `bleak`) are compatible with `bleak` 1.x. Consult `habluetooth` documentation for specific `bleak` version requirements.
Install necessary Bluetooth development packages for your OS. For Debian/Ubuntu: `sudo apt-get install libbluetooth-dev`. For Fedora: `sudo dnf install bluez-libs-devel`.
Upgrade your Python environment to version 3.11 or later.
Ensure your application uses `asyncio` for running the main loop and handling Bluetooth events. Familiarize yourself with Python's asynchronous programming model.
Ensure the Bluetooth adapter is plugged in, powered on, and recognized by the host OS. For Docker, grant `NET_ADMIN` and `NET_RAW` capabilities to the container and ensure `/run/dbus` is mapped. For VMs, ensure the USB Bluetooth adapter is passed through correctly. Restart the host's Bluetooth service (`sudo service bluetooth restart` or `sudo systemctl restart bluetooth`).
Install the required Bluetooth development packages on your host system or inside your Docker container (if applicable). For Debian/Ubuntu-based systems, use `sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev`. For other distributions, find equivalent packages.
Instead of directly using `BleakScanner.find_device_by_address`, use the Home Assistant Bluetooth APIs, specifically `bluetooth.async_get_discovered_device_by_address` or similar functions provided by the `home-assistant-bluetooth` library, which handle device discovery and management within the Home Assistant context.
This often points to a deeper issue with adapter detection or driver loading. Ensure the Bluetooth adapter is fully supported by the host OS and Home Assistant (check documentation for known working adapters). Try updating host OS kernel and Bluetooth drivers, rebooting the entire host system, or providing more specific hardware details in your Home Assistant configuration if possible. Sometimes, physically reconnecting a USB adapter helps.