Unlocking Custom BLE Devices: Integrating Home Assistant with ESPHome Bluetooth Proxy for Advanced Sensors

NGC 224
DIY Smart Home Creator
The Challenge: Bridging the Bluetooth LE Gap in Home Assistant
Many smart home enthusiasts stumble upon the limitations of direct Bluetooth Low Energy (BLE) integration in Home Assistant. While some popular devices have native integrations, a vast ecosystem of niche, custom, or older BLE sensors often remain inaccessible. Your Mi Flora plant sensor in the garden, a specialized environmental monitor in the attic, or even a DIY BLE beacon broadcasting custom data – these devices often operate out of range of your main Home Assistant server's Bluetooth adapter, or simply lack a supported integration. The problem isn't just range; it's about bringing the data from these isolated islands into your centralized smart home hub without proprietary gateways or complex custom code.
This is where the ESPHome Bluetooth proxy shines. By leveraging inexpensive ESP32 microcontrollers, you can create a distributed network of Bluetooth gateways that extend Home Assistant's reach across your entire home. This guide will walk you through setting up ESPHome Bluetooth proxies, integrating previously unsupported BLE devices, and transforming your smart home's sensor capabilities.
Step-by-Step Setup: Deploying Your ESPHome Bluetooth Proxy
1. Prerequisites: What You'll Need
- Home Assistant Instance: A running Home Assistant installation.
- ESPHome: The ESPHome add-on (via Supervisor) or CLI installed and configured.
- ESPH32 Development Board: Any ESP32 board (e.g., ESP32-WROOM-32, ESP32-S3 DevKitC). Ensure it's Wi-Fi capable.
- USB Cable: For flashing the ESP32.
- BLE Device: A Bluetooth Low Energy device you wish to integrate (e.g., Xiaomi Mi Flora, Govee H5075/H5074, or a custom BLE broadcaster).
2. Configure ESPHome for Bluetooth Proxy
Create a new ESPHome device configuration for your ESP32. The core of the Bluetooth proxy functionality lies in two components: esp32_ble_tracker
and bluetooth_proxy
. This setup allows your ESP32 to scan for BLE advertisements and forward them to Home Assistant.
Here's a minimal .yaml
configuration:
# Example: esp32-ble-proxy.yaml
esp32:
board: esp32dev
framework:
type: arduino
wifi:
ssid: "YOUR_WIFI_SSID"
password: "YOUR_WIFI_PASSWORD"
manual_ip:
static_ip: 192.168.1.XX # Choose a static IP outside your DHCP range
gateway: 192.168.1.1
subnet: 255.255.255.0
# Optional: Enable mDNS for easy discovery
mdns:
# Enable the API for Home Assistant communication
api:
encryption:
key: "YOUR_API_ENCRYPTION_KEY" # IMPORTANT: Generate a strong encryption key
# Enable OTA updates
otta:
# Enable logging for debugging
logger:
# Enable the ESP32 BLE tracker
esp32_ble_tracker:
# Enable the Bluetooth Proxy component
bluetooth_proxy:
active: true # Set to true to enable proxying active connections (e.g., HomeKit, custom integrations)
min_advertisement_rssi: -100 # Adjust to filter weak signals. Lower (e.g., -100) means more signals.
Key considerations:
- Replace
YOUR_WIFI_SSID
,YOUR_WIFI_PASSWORD
, and192.168.1.XX
with your network details. - Generate a strong
YOUR_API_ENCRYPTION_KEY
for security. active: true
is crucial if you plan to use integrations that require active connections (e.g., HomeKit BLE devices). For passive monitoring, it's not strictly required but generally recommended.
3. Flash Your ESP32 Board
With your YAML configuration ready, connect your ESP32 board to your computer via USB. Open the ESPHome dashboard in Home Assistant (or use the CLI). Select your newly created configuration and click "Install." Choose your port and flash the firmware. Once flashed, disconnect the USB, power the ESP32 via a stable power supply (a phone charger works well), and place it strategically within range of your target BLE devices.
4. Discovering BLE Devices in Home Assistant
Once your ESP32 is online and connected to your Wi-Fi, Home Assistant should automatically detect the new Bluetooth proxy. You'll likely see a notification in your Home Assistant UI under "Settings" -> "Devices & Services" -> "Integrations." The Bluetooth integration should now show your ESP32 as a new adapter.
With the proxy active, Home Assistant's native Bluetooth integration (and any custom components leveraging it) will begin discovering BLE devices broadcasting within range of the ESP32. You may now see new devices populating the "Discovered" section or appear in specific BLE-reliant integrations.
5. Integrating a Sample Passive BLE Device (e.g., Xiaomi Mi Flora via Passive BLE Monitor)
For many passive BLE sensors (like Xiaomi Mi Flora, Govee, Qingping), the Passive BLE Monitor custom component is invaluable. This component decodes advertisement data from various sensors without needing an active connection, making it highly efficient.
Installation (if not already installed):
Install "Passive BLE Monitor" via HACS (Home Assistant Community Store). Restart Home Assistant after installation.
Configuration:
- Go to "Settings" -> "Devices & Services" -> "Integrations."
- Click "Add Integration" and search for "Passive BLE Monitor."
- In the configuration flow, enable "Use active scan" if your device requires it (most passive devices do not).
- You'll need the MAC address of your BLE device. For some devices (e.g., newer Mi Flora), you might also need a "bind key" or "encryption key." Apps like nRF Connect (Android/iOS) or Xiaomi Cloud Tokens Extractor can help retrieve these.
- Add your device's MAC address and optional encryption key.
Example YAML (if configuring manually, though UI is preferred):
# configuration.yaml
bluetooth:
ble_monitor:
# Optional: use_active_scan: true
devices:
- mac: "C4:7C:8D:6A:B1:23" # Replace with your Mi Flora MAC address
name: "My Garden Mi Flora"
# encryption_key: "abcdef1234567890abcdef1234567890" # Only if required by your specific sensor model
- mac: "A4:C1:38:XX:YY:ZZ"
name: "Living Room Govee Temp"
Once configured, restart Home Assistant. New sensor entities (e.g., `sensor.my_garden_mi_flora_temperature`, `sensor.my_garden_mi_flora_moisture`) will appear, fed by the data proxied by your ESP32.
Troubleshooting Common Issues
Devices Not Showing Up or Sporadic Readings
- Range and Obstructions: Bluetooth signals are weak. Ensure the ESP32 proxy is within reasonable range of the BLE device and minimize physical obstructions (walls, metal objects).
- ESPHome Logs: Check the ESPHome logs for your proxy device. Look for errors related to Wi-Fi connectivity, API connection to HA, or messages indicating BLE scan activity.
- BLE Device Status: Is the BLE device powered on and broadcasting? Some devices have sleep modes or only broadcast periodically. Ensure batteries are fresh.
- Home Assistant Bluetooth Integration: Verify that the main Home Assistant Bluetooth integration recognizes your ESP32 proxy. Go to "Settings" -> "Devices & Services" -> "Integrations" -> "Bluetooth."
- Active Scan (Passive BLE Monitor): For some passive devices, enabling
use_active_scan: true
in Passive BLE Monitor might be necessary to wake them up or force them to advertise more frequently. - Min Advertisement RSSI: In your ESPHome
bluetooth_proxy
configuration, try loweringmin_advertisement_rssi
(e.g., to-100
) to pick up weaker signals.
ESPHome Device Connectivity Issues
- Wi-Fi Connectivity: Double-check your Wi-Fi SSID and password in the ESPHome YAML. Ensure the static IP is correct and not conflicting.
- Power Supply: Use a stable 5V, 1A (or higher) power supply for your ESP32. Unstable power can lead to intermittent disconnections.
- Firmware Version: Ensure both your ESPHome add-on/CLI and the ESPHome firmware on your ESP32 are up to date.
Advanced Configuration and Optimization
Deploying Multiple ESPHome Proxies for Whole-Home Coverage
For larger homes, a single ESP32 might not cover all your BLE devices. Deploy multiple ESP32 proxies strategically. Each proxy acts as an independent gateway, and Home Assistant automatically aggregates the BLE data from all connected proxies. This provides a robust, mesh-like coverage for your BLE devices.
Simply repeat the setup process for each additional ESP32, ensuring each has a unique name and static IP address in its ESPHome configuration.
Optimizing ESP32 BLE Tracker Settings
While the default `esp32_ble_tracker` settings are usually sufficient, you can fine-tune them if you encounter issues or want to conserve resources (though often not necessary for simple proxying).
# esp32_ble_tracker:
# scan_parameters:
# interval: 100ms # How often to start a new scan (default: 320ms)
# window: 100ms # How long to scan within each interval (default: 300ms)
# duration: 5000ms # Total duration of a scan before pausing (default: 5s)
Adjusting these can impact how quickly devices are detected or how much power the ESP32 consumes. For a proxy, the defaults are usually good for continuous scanning.
Filtering Advertisements at the ESPHome Level (Advanced)
For very specific use cases, you can use ESPHome's advanced filtering capabilities within esp32_ble_tracker
to only forward advertisements from certain MAC addresses or containing specific data. This can reduce network traffic if you have a very noisy BLE environment, but it's rarely needed for the general Bluetooth proxy.
# esp32_ble_tracker:
# on_ble_advertise:
# - mac_address: AABBCCDD_EEFF
# then:
# - logger.log: "Found my specific device!"
# - bluetooth_proxy.on_ble_advertise_filter: # Not a real component, just illustrative.
# Custom logic is usually needed here.
Note: Direct filtering for `bluetooth_proxy` is not as straightforward as logging. The `bluetooth_proxy` component simply forwards all discovered advertisements. If you need to filter, you might consider custom C++ components or specific integrations that filter at the Home Assistant level.
Security Considerations and Network Isolation
- API Encryption Key: Always use a strong, unique API encryption key in your ESPHome configuration.
- Separate VLAN: For enhanced security, consider placing all your ESPHome devices (and other IoT devices) on a separate VLAN, restricting their access to only necessary services (e.g., Home Assistant's API port, NTP, DNS) while allowing them to communicate with each other.
Real-World Example: Automating Plant Care with Mi Flora and ESPHome BLE Proxy
Imagine you have several plants across your home and garden, each monitored by a Mi Flora sensor. Your Home Assistant server's Bluetooth range doesn't reach them all. Here's how ESPHome Bluetooth proxies enable comprehensive, automated plant care.
Scenario:
Three Mi Flora sensors: one in the living room, one on the balcony, and one in the garden. Two ESP32s: one near the balcony, one in the garage with good garden coverage.
Setup:
- Deploy two ESP32 Bluetooth proxies as described above, placing them to maximize coverage for the Mi Flora sensors.
- Install and configure the "Passive BLE Monitor" integration in Home Assistant, adding the MAC addresses and any required encryption keys for all three Mi Flora sensors.
- Verify that entities like `sensor.balcony_plant_moisture`, `sensor.garden_plant_temperature`, etc., are now available in Home Assistant.
Home Assistant Automation (Example):
# automations.yaml
- id: 'water_dry_plants'
alias: 'Automate Watering Dry Plants'
description: 'Notify when plant moisture is low and trigger watering.'
trigger:
- platform: numeric_state
entity_id: sensor.balcony_plant_moisture
below: 20 # Threshold for low moisture
for:
minutes: 30
- platform: numeric_state
entity_id: sensor.garden_plant_moisture
below: 25 # Garden might need slightly different threshold
for:
hours: 1
condition:
# Optional: Only water if current time is between 8 AM and 6 PM
- condition: time
after: '08:00:00'
before: '18:00:00'
action:
- service: notify.mobile_app_your_phone
data:
message: "{{ trigger.to_state.attributes.friendly_name }} moisture is critically low ({{ trigger.to_state.state | round(1) }}%). Time to water!"
title: "Plant Watering Alert"
# Example: Trigger a smart switch connected to a pump or sprinkler valve
- service: switch.turn_on
target:
entity_id: switch.garden_irrigation_valve # Replace with your switch entity
- delay: "00:00:30" # Water for 30 seconds
- service: switch.turn_off
target:
entity_id: switch.garden_irrigation_valve
- service: persistent_notification.create
data:
title: "Plant Watering Action"
message: "Watered {{ trigger.to_state.attributes.friendly_name }} due to low moisture."
mode: single
This automation uses the moisture data proxied by your ESP32s to intelligently notify you or even trigger an automated watering system, ensuring your plants thrive no matter where they are located.
Best Practices and Wrap-up
- Strategic Placement: Place your ESP32 proxies to maximize BLE coverage, ideally in central locations or near the specific devices they are meant to monitor.
- Stable Power: Always use reliable power supplies for your ESP32s. Brownouts or flaky power can lead to instability.
- Firmware Updates: Regularly update your ESPHome firmware and Home Assistant to benefit from bug fixes, performance improvements, and new features related to Bluetooth.
- Monitoring: Keep an eye on your ESPHome device's logs and uptime in Home Assistant to ensure they are consistently online and proxying data.
- Backup ESPHome Configs: Save your ESPHome YAML configurations. These are small files, but crucial for quickly rebuilding a proxy if an ESP32 fails.
By harnessing the power of ESPHome Bluetooth proxies, you transform Home Assistant into a truly ubiquitous smart home hub, capable of integrating a wider array of devices and enabling more sophisticated, location-aware automations. This approach is not only cost-effective but also enhances the robustness and flexibility of your entire smart home ecosystem.

NGC 224
Author bio: DIY Smart Home Creator