Mastering Granular Presence: Passive BLE Tracking with ESPHome and Home Assistant

Why Granular Presence Matters
In smart homes, presence detection is fundamental to creating truly automated experiences. Turning lights on when you enter a room, pausing media when you leave, or adjusting climate based on occupancy all rely on knowing who is where. Traditional methods like device trackers based on router connections or Home Assistant companion app location tracking are great for home/away status, but often lack the granularity needed for room-level or even zone-level automation.
This is where passive Bluetooth Low Energy (BLE) tracking shines. By using low-cost, low-power BLE receivers placed strategically around your home, you can detect the presence of devices that broadcast BLE signals, such as smartphones, smartwatches, fitness trackers, and dedicated BLE beacons. When integrated with Home Assistant via ESPHome, this opens up possibilities for highly accurate and localized presence detection.
How Passive BLE Tracking Works with ESPHome
The concept is simple: dedicated BLE scanner devices (typically ESP32 or ESP8266 microcontrollers running ESPHome) are placed in different rooms or areas of your home. These devices continuously scan the airwaves for BLE advertisements from nearby devices. Instead of *connecting* to the devices, they merely *listen* for their broadcast signals.
When an ESPHome device detects a specific BLE address you're interested in (like your phone's Bluetooth MAC address or a beacon's UUID/MAC), it reports this event or the signal strength (RSSI) back to Home Assistant. By analyzing which scanner node detects a device, and potentially the signal strength reported by different nodes, Home Assistant can infer the location of the device and, by extension, the person carrying it.
Prerequisites
- A working Home Assistant instance.
- The ESPHome add-on installed in Home Assistant (or ESPHome running elsewhere with API access to HA).
- One or more ESP32 or ESP8266 development boards. ESP32 is highly recommended due to its superior BLE capabilities compared to ESP8266.
- Devices that broadcast a stable, discoverable BLE signal (e.g., a smartphone/watch with Bluetooth enabled, dedicated BLE beacons like iBeacons or ESPHome-based beacons).
- A way to find the BLE address of the device(s) you want to track (e.g., using mobile apps like nRF Connect or BLE Scanner).
Setting up ESPHome for BLE Tracking
If you haven't already, install the ESPHome add-on via the Home Assistant Add-on Store. Once installed and started, open its web UI.
Click 'Add New Device' and follow the steps to create a configuration for your ESP32 board. Choose your board type (e.g., ESP32-WROOM-32). Give it a name (e.g., ble_scanner_livingroom
).
The core of the configuration involves the esp32_ble_tracker
component (for ESP32). For simplicity and leveraging newer Home Assistant features, you should also enable the bluetooth_proxy
component. This allows the ESPHome device to act as a remote Bluetooth adapter for Home Assistant's built-in Bluetooth integration.
Here's a basic ESPHome configuration snippet:
esp32:
board: esp32dev
framework:
type: esp-idf
bluetooth_proxy:
esp32_ble_tracker:
api:
encryption:
key: !secret esphome_api_key
# ... other configurations like wifi, ota, logger ...
Replace esp32dev
with your specific board type. Ensure you have Wi-Fi and API configurations set up correctly. The esp32_ble_tracker:
line enables the scanner, and bluetooth_proxy:
makes it available to Home Assistant.
To find the BLE address of devices you want to track, use an app like nRF Connect on Android or iOS. Scan for devices and note the public or static random addresses. Some devices use rotating private addresses, which are not suitable for long-term tracking without specific manufacturer support.
Once the configuration is ready, install it on your ESP32 device. You can do this wirelessly via OTA updates after the initial flash over USB, or perform the first flash using the ESPHome web installer or command line.
Integrating with Home Assistant
With the bluetooth_proxy
component enabled in your ESPHome configuration and the device online, Home Assistant should automatically discover the ESPHome board as a Bluetooth adapter via the Home Assistant Discovery mechanism. You'll see a notification to set up the 'Bluetooth' integration. Follow the prompts, and it will list your ESPHome device as an available adapter.
Once integrated, Home Assistant's built-in Bluetooth integration will start receiving data from the ESPHome scanner. Devices detected by the scanner (including those broadcasting passive advertisements) will appear as new devices and entities in Home Assistant. Often, these appear as device_tracker
entities or simply as devices with attribute updates showing discovery/RSSI information.
Creating Room/Zone Presence Logic
The real power comes from using the information from multiple scanners. If you have scanners in your living room (ble_scanner_livingroom
) and kitchen (ble_scanner_kitchen
), you can determine if a device (e.g., device_tracker.my_phone_ble
) is in the living room if it's detected by ble_scanner_livingroom
with a strong signal, but not by ble_scanner_kitchen
(or with a much weaker signal).
You can create Template Binary Sensors or use Home Assistant automations with Choose actions or conditions based on the state or attributes (like RSSI) of the device tracker entities provided by the Bluetooth integration and the ESPHome proxy.
Example Automation Logic (Conceptual):
automation:
- alias: "Someone entered Living Room"
trigger:
- platform: state
entity_id: device_tracker.my_phone_ble
attribute: source # Or similar attribute indicating the scanner
from: null # Was not seen before
to: bluetooth_proxy_livingroom # Seen by living room scanner
# Add conditions based on other scanners if needed
condition: [] # Example: Ensure not seen by kitchen scanner
action:
- service: light.turn_on
target:
entity_id: light.living_room_lamps
More advanced logic can involve comparing RSSI values from multiple scanners or using Bayesian probability binary sensors for more robust zone determination.
Device Integration Tips
- Choose ESP32: While ESP8266 can do some basic scanning, ESP32 is significantly better for BLE tracking due to dedicated hardware.
- Strategic Placement: Place scanners in key areas (living room, kitchen, bedroom, office). Consider areas with doors or hallways as potential transition points. Avoid placing them near large metal objects or thick walls that can block BLE signals.
- Stable BLE Addresses: Relying on smartphone BLE addresses can be unreliable as some operating systems randomize addresses for privacy. Dedicated BLE beacons (like iBeacons, Eddystone, or even ESPHome acting as a beacon) provide stable, predictable addresses.
- Finding Addresses: Use mobile apps like nRF Connect or BLE Scanner to identify the BLE addresses and types of nearby devices. Beacons will often broadcast UUIDs and major/minor values in addition to MAC addresses.
Best Practices for Reliability
- Multiple Nodes are Key: A single scanner only tells you if a device is nearby. Multiple scanners allow triangulation or comparison for zone accuracy. The more nodes, the more precise your location data can be.
- Dedicated Beacons: For tracking people, having them carry a small, dedicated BLE beacon (a Tile tracker, an iBeacon, or even a small ESP32 broadcasting as a beacon) is far more reliable than hoping their phone's Bluetooth stays on and broadcasting a stable address.
- Combine Presence Methods: Don't rely solely on BLE. Combine it with other methods like router-based tracking (for overall home presence), Home Assistant app location (for away status), or even motion sensors for a layered, robust presence detection system. Use BLE for the final layer of room-level accuracy.
- Monitor ESPHome Nodes: Ensure your ESPHome devices are online and healthy. Use the built-in sensor data ESPHome provides (like uptime, Wi-Fi signal) to monitor their status within Home Assistant.
- Consider Signal Strength (RSSI): While simple detection is a start, using RSSI values from multiple nodes can improve accuracy. A device is likely closer to the scanner reporting a stronger (less negative) RSSI.
Conclusion
Integrating passive BLE tracking using ESPHome and Home Assistant is a powerful way to enhance your smart home's understanding of who is where. While initial setup requires identifying device addresses and configuring ESPHome nodes, the result is a robust and granular presence detection system that can drive more intelligent and responsive automations, truly bringing your smart home to life room by room.

NGC 224
Author bio: