Tracking pet presence with a Bluetooth LE beacon, Home Assistant, Bermuda from HACS and a median sensor

Tracking pet presence with a Bluetooth LE beacon, Home Assistant, Bermuda from HACS and a median sensor

Knowing the last time your pet went outside can be incredibly useful—whether you want to manage outdoor time, track routines, or simply ensure they’re safe. I recently set up a solution using a Bluetooth LE (BLE) beacon, the Bermuda BLE Trilateration integration from HACS, and some smart templating in Home Assistant. In this post, I’ll walk you through how I built a reliable system that logs when my pet leaves and returns home.

Why Track Your Pet’s Last Outdoor Time with BLE Beacons?

Bluetooth LE beacons offer a lightweight and cost-effective way to monitor your pet’s presence at home. I picked up a BLE beacon from AliExpress for about $5 that fits neatly into an Airtag case.

Key benefits:

  • Accuracy: Know exactly when your pet goes outside and comes back.
  • Battery-efficient: BLE beacons can last months on a single battery.
  • Cost-effective: No subscription fees or expensive hardware.

Power on the BLE beacon and get the MAC Address

The first step was to find the MAC address of the BLE beacon. This can be tricky since there might be many Bluetooth devices in the area. Using a Bluetooth scanner app on my phone made this part easier.

💡
Tip: Make sure to label the beacon to avoid confusion with other nearby devices.

Install the Bermuda Integration from HACS

To integrate the BLE beacon with Home Assistant, I used the Bermuda BLE Trilateration integration available via HACS. Bermuda allows you to create device_tracker entities based on Bluetooth signals detected by Bluetooth proxies around the house.

Configuration:

  • Add Bermuda via HACS.
  • Configure it using the MAC address of your BLE beacon.
  • This creates a device with a device_tracker entity that reports the beacon’s distance and timestamps.

Reducing Noise with a Median Sensor

One challenge with BLE tracking is signal noise, which can cause unreliable readings. To smooth out the data without sacrificing responsiveness, I created a median sensor in Home Assistant:

  • Sensor type: Template median sensor.
  • Window: Last 30 seconds of distance readings.
  • Fallback: Retains the last known value when the beacon is out of range (preventing the distance from showing as unknown).

Why a median sensor?
Using a median instead of an average helps filter out occasional spikes or drops in signal strength that might incorrectly report your pet as being away.

Creating a Binary Sensor for Home and Away Status

To simplify things, I created a template binary sensor that turns on when my pet is not home and off when he’s back. This sensor also logs timestamps for the last time my pet was seen leaving or returning home.

{{ (states('sensor.trey_via_harness_distance_median') | float(0)) > 20 or is_state('device_tracker.trey_via_harness', 'not_home') }}

binary_sensor.trey_on_a_walk (template sensor)

Conclusion

Tracking your pet’s last outdoor time with a BLE beacon, Bermuda integration, and median sensors in Home Assistant is a simple yet powerful way to enhance your smart home. The ability to get accurate timestamps and reliable presence detection makes it a game changer. If you’re looking for a smart way to monitor your pet’s outdoor habits, this setup is worth trying.

Happy tracking!