Important
Superseded on ESPHome 2026.10 and later by
esphome-ble-advert-filter.
ESPHome 2026.10 ships an advertisement filter hook in stock bluetooth_proxy
(esphome/esphome#19220), and that
component plugs the same filter into it, so there is no fork of a core component to update on
every release. Same options, same methods; moving is mechanical, see its
migration guide.
This fork stays for ESPHome 2026.9 and earlier. Its v1.8.2 filter matches
esphome-ble-advert-filter v2.0.4 (fixes and the RPA verdict cache are ported here;
tools/check_parity.py checks it). The sensor and number platforms and the
set_irks/clear_irks actions exist only in esphome-ble-advert-filter.
A drop-in fork of ESPHome's core bluetooth_proxy component that can filter BLE
advertisements on the device, before they are queued for the API and cross the network.
Core ESPHome's bluetooth_proxy accepts only active, cache_services,
connection_slots and connections — it has no RSSI, MAC or name filtering of any
kind, and on_raw_advertisement_() forwards every packet it receives. The
mac_address / service_uuid / manufacturer_id options on esp32_ble_tracker apply
only to its on_ble_advertise automation triggers and do not gate the proxy stream.
This fork adds the options below. All default to "off", so an unconfigured build behaves exactly like upstream.
| Option | Effect |
|---|---|
rssi_threshold |
RSSI limit for everything not matched by a protection category (default -127 = forward everything) |
irks |
Drop Resolvable Private Addresses that resolve to none of the listed Identity Resolving Keys — i.e. other people's phones and watches |
mac_allowlist |
Always forward these addresses, whatever else is blocked (except mac_blocklist). Only rssi_mac_allowlist and rssi_floor bound them |
rssi_floor |
Absolute reception limit for every category, allowlisted ones included, except an allow_ibeacon or allow_findmy rule that sets its own rssi (default -127 = off) |
rssi_mac_allowlist |
RSSI limit for mac_allowlist hits (default -127 = bounded only by rssi_floor) |
rssi_irk |
RSSI limit for IRK-matched devices (default -127 = inherit rssi_threshold) |
rssi_service_uuid |
RSSI limit for service_uuid_allowlist hits (default -127 = inherit rssi_threshold) |
manufacturer_blocklist |
Drop advertisements carrying these Bluetooth SIG company identifiers (AD type 0xFF) |
name_blocklist |
Drop advertisements whose local name contains one of these substrings |
drop_non_resolvable |
Drop non-resolvable private addresses — they rotate but carry no identity, so an IRK cannot resolve them and they can never be tracked (default false) |
allow_espressif |
Exempt Espressif-OUI addresses from the IRK test (default true) |
allow_ibeacon |
Exempt iBeacons from manufacturer_blocklist — true for all, or a list of uuid/major/minor/rssi rules (default false) |
allow_findmy |
Exempt Apple FindMy (Offline Finding) advertisements — AirTags, AirPods, licensed third-party tags — from manufacturer_blocklist: true, or {rssi: -85} to give them their own limit (default false) |
It also exposes advertisement counters (get_adv_forwarded(), get_adv_dropped(),
get_adv_dropped_rpa(), get_adv_forwarded_irk()) so the effect is measurable per-proxy rather
than guessed. get_adv_forwarded_irk() is the one that tells a wrong IRK from an absent phone:
a key that never matches leaves it flat while its owner's adverts are counted as somebody
else's and dropped.
This fork is on its way out. ESPHome 2026.10 ships an
AdvertisementFilterhook in stockbluetooth_proxy, and esphome-ble-advert-filter is this same filter built on it — nothing to re-sync on every release. The two are kept textually identical (tools/check_parity.py, enforced in CI), with the same options and methods. See its README for the (mechanical) migration.
external_components:
- source:
type: git
url: https://github.com/davidcoulson/esphome-bluetooth-proxy-filter
ref: main
components: [bluetooth_proxy]
bluetooth_proxy:
id: ble_proxy
active: true
rssi_threshold: -75
rssi_floor: -90 # bounds mac_allowlist too
allow_espressif: true
mac_allowlist:
- AA:BB:CC:DD:EE:FF # a beacon that must always be forwarded
manufacturer_blocklist:
- 0x004C # Apple - AirPods/AirTags/neighbours' devices
irks:
- !secret ble_irk_my_phone # ...but NOT our own Apple devicesAn advertisement is categorised first, then measured against that category's own RSSI limit. This is what makes the limits independent: any category can be looser or stricter than any other.
mac_blocklisthit → drop, ahead of every allow rule- RSSI below the pre-gate → drop. Global, applies to allowlisted devices too
- Categorise, first hit wins, cheapest test first:
mac_allowlist→MAC· RPA resolving to an IRK →IRK· matched iBeacon →IBEACON· FindMy (withallow_findmy) →FINDMY· allowlisted service UUID →UUID· anything else →DEFAULTAn RPA that resolved to none of your IRKs is dropped here, regardless of RSSI — but only if no other rule claimed it. It used to be dropped before the payload rules ran, which meantservice_uuid_allowlistcould not rescue a device pairing from a resolvable address, the case it exists for. - RSSI below that category's limit → drop
allowlist_exclusiveandDEFAULT→ drop- Non-resolvable private address (with
drop_non_resolvable), unprotected → drop - Blocklisted manufacturer id or local name, unprotected → drop
- Otherwise forward
mac_allowlist deliberately exempts tracked beacons from rssi_threshold, because a
weak reading at one proxy is exactly what places the tag nearer another. But that
exemption used to be unbounded: a tag heard at the receiver's noise limit was still
forwarded, and an RSSI that far down carries no usable distance information. It does
not help a tracker triangulate, it misleads it. rssi_floor bounds the exemption
without removing it.
Before v1.1.0 the single rssi_threshold ran partway down the chain, so only
mac_allowlist could be given a looser limit — IRKs and service UUIDs were resolved
after the threshold had already dropped the advertisement, and their limits could
only tighten. Categorising first fixes that, at the cost of running IRK resolution and
the service-UUID payload walk for advertisements between rssi_floor and
rssi_threshold that the old order discarded earlier. rssi_floor is the mitigation:
cheapest test, runs first, applies to everything.
An unset (-127) category limit inherits, chosen so a config that sets none of
them behaves exactly as it did before v1.1.0: mac_allowlist is bounded only by
rssi_floor; irk and service_uuid inherit rssi_threshold.
Both address-class tests are guarded on addr_type as well as the address bits.
That guard is load-bearing: real public OUIs exist both in the RPA bit range
(Espressif's 4C:…) and the non-resolvable range (00:, 04:, 15:…), and
bit-matching alone would discard them.
Why the categories mark the advertisement "protected": a device matched by an IRK
is one of yours, and your phones and watches advertise Apple manufacturer data.
Without the protected flag, a manufacturer_blocklist: [0x004C] entry would discard
exactly the devices the IRK list exists to keep. The name and manufacturer checks
share a single pass over the payload.
irks: is compile-time, so on its own a new phone means reflashing every
proxy. set_irks() replaces the list at runtime; the usual source is a Home
Assistant entity each proxy subscribes to:
text_sensor:
- platform: homeassistant
entity_id: sensor.ble_proxy_irks
attribute: irks # an attribute: HA caps states at 255 characters
internal: true
on_value:
- lambda: 'id(ble_proxy).set_irks(x);'
# ESPHome logs every attribute it receives at DEBUG, keys included, and
# `internal: true` does not stop that line.
logger:
logs:
homeassistant.text_sensor: WARN
text_sensor: WARNThe parser takes every run of exactly 32 hex characters and ignores the
rest, so the Home Assistant side can keep a name next to each key -
David phone: 0011..., or a stringified dict - and a replacement is an edit
to one named line. The only rule is that no label contains 32 consecutive hex
digits. Runs of 31 or 33 are rejected rather than trimmed, and two keys with
no separator between them (64 digits) are rejected rather than split.
Input with no valid key leaves the current list untouched and returns
-1. An entity that is briefly unavailable during a Home Assistant restart
must not be able to wipe the list: with manufacturer_blocklist: [0x004C] a
wiped list silently drops your own phones. clear_irks() empties it on
purpose.
The compile-time list still loads in setup(); set_irks() replaces it, it
does not merge. get_irks() exposes the live list read-only so a lambda can
persist it to flash for use before Home Assistant connects. Calls are safe at
any time - advertisements and API state updates are both dispatched from the
main loop, so the list is never swapped mid-lookup.
AirTags, AirPods and licensed third-party FindMy tags advertise Apple
manufacturer data with the Offline Finding subtype 0x12, from a random
static address. AirPods near their owner send the proximity-pairing subtype
0x07 instead - the advert that raises the AirPods card on an iPhone - but
from the same rotated address, so allow_findmy exempts that subtype too.
Without it an AirPods case sitting on a desk is heard only by receivers that
run no Apple blocklist. Neither the IRK test nor drop_non_resolvable
touches them, so with manufacturer_blocklist: [0x004C] the Apple entry is
the only thing dropping them - and it drops every one. A tracker that holds an
accessory's pairing keys (Bermuda's FindMy support) can follow its address
rotation, but only if the adverts reach it:
bluetooth_proxy:
manufacturer_blocklist: [0x004C]
allow_findmy: true # inherits rssi_threshold, bounded by rssi_floor
# or, with its own limit (overrides both, like an iBeacon rule):
allow_findmy:
rssi: -85There is no per-accessory scoping: the advert carries no identity a proxy
could act on (the key material that resolves the rotation lives in the
tracker), so every FindMy accessory in range comes through. Bound it with
rssi rather than the fleet threshold when neighbours' tags are the concern.
iBeacon is Apple manufacturer data with subtype 0x02, so a
manufacturer_blocklist: [0x004C] entry — the usual way to kill AirPods, AirTag
and neighbour noise — silently takes every iBeacon with it. allow_homekit
does not help: that exempts subtype 0x06.
This matters if you run BPS receiver auto-calibration, where each ESPHome probe advertises an iBeacon so its siblings can range it. Those adverts come from the probe's public Espressif MAC, so they carry no IRK and nothing else rescues them.
bluetooth_proxy:
manufacturer_blocklist: [0x004C]
allow_ibeacon: true # every iBeacon exemptScope it to your own beacons instead of opening the door to every iBeacon in radio range.
Scope by uuid. major and minor are small integers every vendor starts counting from
1, so a rule that names only major: 1 admits anybody's beacon that was left on its
defaults — and admits it at this rule's rssi, which usually overrides the floor. The UUID is
the only field that says whose beacon it is:
allow_ibeacon:
- uuid: fde3b150-2f64-43ba-aee9-867f75ee4a6f
major: 1 # our probes, and nobody else's major 1
- uuid: 12345678-1234-1234-1234-123456789abc # every major/minor of this uuid
- major: 10
minor: [3, 4, 5] # no uuid: ANY vendor's 10/3, 10/4, 10/5A rule needs a uuid, a major, or both; minor only means something inside a major.
When several rules match, the most specific wins — minor over major over uuid-only, and
a uuid-scoped rule over an unscoped one — whatever order they are written in.
Each filter can carry its own rssi, which overrides both rssi_threshold
and rssi_floor for adverts it matches:
allow_ibeacon:
- uuid: fde3b150-2f64-43ba-aee9-867f75ee4a6f
major: 1
rssi: -95 # our probes: well below the floor
- major: 10
rssi: -85That is the point of the feature. Probe-to-probe ranging wants exactly the weak cross-room readings the fleet threshold exists to discard — and only for the beacons doing the ranging. Everything else stays bounded.
Omitting rssi inherits: the filter exempts the advert from
manufacturer_blocklist and nothing else, so rssi_threshold and rssi_floor
still apply. Omitting a value is never the most permissive setting. A bare
allow_ibeacon: true behaves the same way.
Note rssi: -127 disables the internal pre-gate (see below), so prefer a real
value like -95 unless you genuinely want everything.
Every advert is measured against some limit, so anything weaker than the most permissive
limit in the config is dropped before categorisation runs. That keeps an AES resolve and a
payload walk off every distant advert once your own beacons are allowed through at a low
RSSI. It is derived automatically from rssi_threshold, rssi_floor, every per-category
limit and every rule that brings its own — but only for categories something can actually
land in: with no mac_allowlist there is no allowlisted advert for the gate to protect, so
that category does not hold it open. A reachable category with no bound at all disables it,
correctly — if something is allowed through at any strength, nothing can be rejected on RSSI
alone.
It is recomputed whenever a limit or list changes, including at runtime. It used to be
computed once at codegen, so a Home Assistant number lowering rssi_threshold below the
compiled gate silently stopped working. get_min_rssi_gate() reports the current value.
minor is nested under major because that is the BLE data model — a minor is
only meaningful inside a major — and flat keys cannot express "major 1 minor 7
and major 10 minor 3".
The filters narrow the exemption; they never add a drop rule. An iBeacon
matching none of them falls through to the normal manufacturer test, exactly as
if the exemption were off. A truncated iBeacon carrying no major/minor cannot be
matched, so it is not exempted when filters are in use (bare true still exempts
it).
Note this exempts iBeacons from the payload filters only. The RSSI limits still apply, so distant probe pairs can still be dropped — relevant for calibration, which wants the full pair matrix including weak through-wall links.
On a ~30-proxy Home Assistant install:
- RSSI filter at
-85alone: ~38% fewer bytes on the wire (control-normalised) - Adding IRK filtering: 56–66% of all advertisements dropped
- Unresolved RPAs were a consistent 20–27% of everything each proxy heard
Packet count falls much less than byte count (~14% vs ~38%), because the proxy batches up to 16 advertisements per packet — dropping advertisements mostly makes batches emptier rather than removing packets.
tests/run.shThis fork's bluetooth_proxy.cpp cannot be compiled off-device — it drags in the whole API
server — so it is tested by proxy. tests/run.sh first runs tools/check_parity.py, which
fails if any filter function, the filter chain, the OUI table or the public API differs from
esphome-ble-advert-filter, then
runs that repo's suite, which compiles the real filter source under AddressSanitizer and
UBSan. If the text matches, the fork's logic is the logic that was tested. This replaced
hand-transcribed copies of three functions, which could drift from the source they described.
- Home Assistant discovers BLE devices by hearing them advertise. A device below the RSSI threshold at every proxy becomes invisible to HA entirely, not just to your tracker, and cannot be connected to.
- Re-sync this fork on every ESPHome version bump. It pins a copy of a fast-moving
core component. See
components/bluetooth_proxy/README.mdfor the procedure and the exact diff against upstream.
ESPHome is dual-licensed MIT / GPLv3; this fork carries the upstream licence of the files it derives from.