BLE Adv Rules icon

BLE Adv Rules

A Home Assistant custom integration that turns the Bluetooth Low Energy (BLE) advertisements of devices Home Assistant has no integration for into events and sensors, using rules you build from the user interface.

Bluetooth LE remotes, buttons, beacons and sensors in Home Assistant

Plenty of cheap Bluetooth Low Energy gadgets never connect to anything: a 4-key remote, a thermometer, a button, a beacon. They simply broadcast a short packet, an advertisement, a few times per second, and the information is in the bytes of that packet. If Home Assistant has no integration for the device, you would otherwise need a custom component or an ESPHome lambda just to find out which byte means "key 2 was pressed".

BLE Adv Rules lets you do that from the UI. Nothing connects to the device and nothing is pushed to it: the integration only listens.

How it works

  1. Look at what the device sends: a scan, a capture, or a live "Last advertisement" sensor.
  2. Describe the bytes you care about with a hex pattern, an optional mask and, when needed, a small template.
  3. Get an event entity for button presses and sensor entities for values such as temperature or battery.

In practice: add the integration, scan for nearby devices while you press the button, pick the device, then add an event rule (for a button) or a sensor rule (for a value). Rule setup can listen to the device while you press its buttons, show the captured payloads under a byte-offset ruler, suggest a pattern and preview which captured payloads your rule would match. You can add as many rules as you need to one device, for instance four event rules for a four-key remote.

Example: an event rule with a template

For a 4-key remote whose payload is obfuscated, a rule can check the stable header of the raw packet with a pattern and let a template do the arithmetic the pattern cannot. The values below are the README's synthetic example for "Key 1".

Source:      raw
Pattern:     0201021b05ffffee1b
Match mode:  Starts with
Offset:      0

Template:
{# 0x3b #}{{ raw | count > 22 and raw[20] | bitwise_xor(raw[22]) == 59 }}

The full documentation walks through this and other worked examples, including a button identified by a masked manufacturer byte and a thermometer in service data.

Features

Requirements

Installation

HACS (recommended)

  1. Open HACS, then the menu, then Custom repositories.
  2. Add https://github.com/aikrana/ha-ble-adv-rules with category Integration.
  3. Search for BLE Adv Rules, download it and restart Home Assistant.

Manual

  1. Download ble_adv_rules.zip from the latest release and unpack it into config/custom_components/ble_adv_rules/.
  2. Restart Home Assistant.

Then go to Settings, Devices & services, Add integration, BLE Adv Rules.