Skip to content

Commit f0603e7

Browse files
authored
Document async_clear_address_from_match_history Bluetooth API (#2831)
1 parent bec2b74 commit f0603e7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/core/bluetooth/api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,32 @@ from homeassistant.components import bluetooth
242242
bluetooth.async_rediscover_address(hass, "44:44:33:11:23:42")
243243
```
244244

245+
### Clearing match history for rediscovery
246+
247+
The Bluetooth integration tracks which advertisement fields (manufacturer_data UUIDs, service_data UUIDs, service_uuids) have been seen for each device to determine when to trigger discovery. It only checks if the UUIDs have been seen before, not whether their content has changed.
248+
249+
For devices that change state but maintain the same UUIDs (such as devices that are factory reset or transition between operational states), you can clear the match history to allow rediscovery when the device advertises again with different content.
250+
251+
The `bluetooth.async_clear_address_from_match_history` API clears the match history for a specific address without immediately re-triggering discovery. This differs from `async_rediscover_address`, which clears history AND immediately re-triggers discovery with cached data.
252+
253+
Use this API when:
254+
- A device is factory reset (state changes but UUIDs remain the same)
255+
- A device transitions between operational states with the same advertisement UUIDs
256+
- You want to prepare for future rediscovery without immediately triggering a flow
257+
258+
```python
259+
from homeassistant.components import bluetooth
260+
261+
# Clear match history to allow future advertisements to trigger discovery
262+
bluetooth.async_clear_address_from_match_history(hass, "44:44:33:11:23:42")
263+
```
264+
265+
:::warning Performance Considerations
266+
Do not use this API for devices whose advertisement data changes frequently (e.g., sensors that update temperature readings in advertisement data). Clearing match history for such devices will cause a new discovery flow to be triggered on every advertisement change, which can overwhelm the system and create a poor user experience.
267+
268+
This API is intended for infrequent state changes such as factory resets or major operational mode transitions, not for regular data updates.
269+
:::
270+
245271
### Waiting for a specific advertisement
246272

247273
To wait for a specific advertisement, call the `bluetooth.async_process_advertisements` API.

0 commit comments

Comments
 (0)