How to create a Bluetooth tracker with Home Assistant and ESPHome Version 2

by Pete
13 minutes read

Welcome back to our exploration of home automation using Bluetooth beacons! In our previous article, we discussed setting up a device tracking system with iTags. Today, we’re taking this a step further by integrating HolyIoT Bluetooth beacons, known for their enhanced reliability and superior features.

NRF51822 Bluetooth Beacon Tag Eddystone Ibeacon BLE 4.2 Proximity Locator Beacon Automation Modules for Indoor Navigation IOTImage lifted from the AliExpress website

Why HolyIoT Beacons?

HolyIoT beacons provide several advantages over traditional iTags, including:

  • Longer Battery Life: I found that that I was swapping out batteries every month while using the iTag. Not only is this wasteful, but impractical. The Y1 is rated for 12-24 months of expected battery life instead of <1 month.
  • Enhanced Signal Stability: One big advantage the Y1 device has over the iTag is that it’s a BLE Beacon. No buttons, always broadcasting and at a very low power.
  • Advanced Features: The other challenge with the iTag is that the device would stop broadcasting if there wasn’t a connection over a long period of time. Resulting in loss of reporting, and therefore loss of overall reliability.
  • Size matters: There is one downside to the Y1 and that its size. It’s larger and bulkier than the iTag and also requires a larger battery. The Y1 case is enclosed, while slick, doesn’t include a keyring hole as its purpose is to be mounted on a wall or stuck to a device. Therefore, I needed to design and print my own case that fits my keyring.
  • If you’re interested in purchasing one, I sourced mine from the HolyIoT AliExpress page.

Design Concept

The overall design isn’t too dissimilar to the iTag setup and the premise is the same.

Each ESP32 “BLE Hub” is aware of each HolyIoT device and will track its connectivity and signal strength which is reported back to Home Assistant.

I placed an ESP32 in each room / specific location around the house. In the diagram, I mentioned Garage, Dining Room and Hallway. In actual fact there another 3 around the property that will capture locations of these beacons as they roam.

Getting this work

To get this working, we need to create a sensor YAML file for each HolyIOT device.

Create a Sensor File for each HolyIoT device

As we’re simply using ble_rssi in ESPHOME, the configuration for each device is very straightforward. I created a YAML file for each beacon to share around each ESP32 BLE Hub.


  - platform: ble_rssi
    mac_address: "AA:BB:CC:DD:EE:FF"
    name: "holy-iot01 $location RSSI"

You can retrieve the MAC from any BLE enabled device such as a laptop, desktop or your phone (iPhone users will need a BLE Scanning app – there are plenty available for free).

You’ll subtly notice the holy-iot01 $location RSSI code. This is a variable to generate a “location” entity for the device it’s compiled to.

E.g. for esp32s04 device – which is situated in the “Hallway”.

# ES32 used for BLE Tracker / Door Sensor Hub 04 - Hallway
### Substitutions ###
  device_name: esp32s04
  friendly_name: $device_name
  location: Hallway

I use a substitution to specify the location of the device, and therefore, an entity will be created for each device added.

I want the ESP32 to report back to Home Assistant, the RSSI value for the “holy-iot <location> RSSI” so I can use an automation to determine where the device is and to determine what BLE tracker its closest to.

Because I have three keys with HolyIoT devices, for each ESP32, I will have one “location” entity per HolyIoT as shown in the image above.

Reuse our previous BLE Tracker configuration.

In How to create a Bluetooth tracker with Home Assistant and ESPHome, we created an esp32_ble_tracker.yaml config file. We can reuse this as nothing has changed apart from a few window and interval tweaks to speed up the response.


     window: 30ms
     interval: 100ms

Updating each ESP32 Device

We can apply the new configuration files to each ESP32 that we want to be HUBs.

Make sure your ESP32 has BLE tracker enabled by placing the code in the global section of the code. I use !include files as it’s repeatable.

<<: !include common/devboards/esp32/esp32_ble_tracker.yaml

Next is to load up the sensor: area with each HolyIoT yaml file, populating each ESP32 with the same so every ESP32 BLE HUB “knows” about all sensors.

Again, I use !include files so I can copy paste the same code into each ESP32 device YAML file.

  - <<: !include common/components/holy-IOT/sensor_holy-iot01.yaml #Spare Keys
  - <<: !include common/components/holy-IOT/sensor_holy-iot02.yaml #Pete's Keys
  - <<: !include common/components/holy-IOT/sensor_holy-iot03.yaml #Kate's Keys

Using automations and helpers to bring it together.

Automations and helpers are the final pieces of the puzzle.

We need to create the following:

  1. A helper for each HolyIoT device
  2. An automation for each HolyIoT device

The automation will update the helper to display the final “location” of the device.

I called mine simply “Holy-IOTxx Location” for each automation and helper.

Each automation is essentially same, except for the iotxx naming convention. Here is the automation YAML for Holy-IOT01 Location:

alias: Holy-IOT01 Location
description: ""
  - platform: time_pattern
    seconds: /15
condition: []
  - service: input_text.set_value
    entity_id: input_text.holy_iot01_location
      value: >-
        {% macro get_rssi(sensor_id) %}
          {% set rssi = states(sensor_id) %}
          {{ rssi if rssi != 'unknown' else -100 | float }}
        {% endmacro %}
        {% set dining_room_rssi = get_rssi('sensor.holy_iot01_dining_room_rssi')
        | float %} {% set garage_rssi =
        get_rssi('sensor.holy_iot01_garage_rssi') | float %} {% set hallway_rssi
        = get_rssi('sensor.holy_iot01_hallway_rssi') | float %} {% set
        shed_workshop_rssi = get_rssi('sensor.holy_iot01_shed_workshop_rssi') |
        float %} {% set master_bedroom_rssi =
        get_rssi('sensor.holy_iot01_master_bedroom_rssi') | float %} {% set
        study_rssi = get_rssi('sensor.holy_iot01_study_rssi') | float %} {% set
        lounge_room_rssi = get_rssi('sensor.holy_iot01_lounge_room_rssi') |
        float %}
        {% set max_rssi = max([dining_room_rssi, garage_rssi, hallway_rssi,
        shed_workshop_rssi, master_bedroom_rssi, study_rssi, lounge_room_rssi])
        {% if max_rssi == -100 %}  
           Not at Home
        {% elif max_rssi == shed_workshop_rssi %}
            Shed Workshop 
        {% elif max_rssi == master_bedroom_rssi %}
            Master Bedroom 
        {% elif max_rssi == hallway_rssi %}
        {% elif max_rssi == dining_room_rssi %}
            Dining Room 
        {% elif max_rssi == garage_rssi %}
        {% elif max_rssi == study_rssi %}
        {% elif max_rssi == lounge_room_rssi %}
            Lounge Room
        {% else %}
            Error in Locating
        {% endif %}
mode: single


  1. Each YAML is run every 15 seconds to capture the current signal strength
  2. The logic coding to determine the max values seems to work better and faster than the previous comparison code
  3. The logic code is more accurate and quicker to update – still not perfect – there might be a 15-30 window when the code is cycling and the HolyIot’s are roaming between close device but overall, the code works well.

Displaying the locations of my keys in a friendly manner

My Lovelace card looks like this by simply using a tile card outputting the value of the helper sensors:

And yes, all key locations are being reported accurately.

3D Printed Keyring Enclosure


In this journey from iTags to HolyIoT beacons, we’ve significantly improved our home automation setup. By integrating HolyIoT beacons with ESPHome and Home Assistant, we’ve achieved more reliable, long-lasting, and efficient device tracking across various locations in our home. The extended battery life and enhanced signal stability of the HolyIoT beacons ensure that we can enjoy a maintenance-free system for up to two years, a massive upgrade from the monthly battery replacements required by iTags.

Moreover, the advanced features of the HolyIoT beacons, such as their continuous broadcasting ability, have eliminated the common issue of signal dropout, making our system more robust and dependable. Although the size of the beacons posed a slight challenge, a custom-designed keyring case provided a simple and effective solution.

The automation logic developed for the HolyIoT beacons has not only improved the speed but also the accuracy of location tracking, allowing us to pinpoint the location of keys and other items with minimal delay. This setup is not just about convenience; it represents a leap towards a truly intelligent and responsive home environment.

For those looking to replicate or adapt this setup, remember that the principles laid out here can be applied to other BLE devices and automation scenarios. Whether you’re tracking pets, personal items, or optimizing other aspects of your smart home, the flexibility and scalability of ESPHome with HolyIoT beacons offer a robust foundation for your creative automation projects.

I encourage you to share your experiences and tweaks as you integrate HolyIoT beacons into your home automation systems. Together, we can continue to refine and enhance our smart homes, pushing the boundaries of what’s possible with current technology.