Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions homeassistant/components/bluetooth/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,23 +413,20 @@ def scanner_adv_received(self, service_info: BluetoothServiceInfoBleak) -> None:

# Pre-filter noisy apple devices as they can account for 20-35% of the
# traffic on a typical network.
advertisement_data = service_info.advertisement
manufacturer_data = advertisement_data.manufacturer_data
if (
len(manufacturer_data) == 1
and (apple_data := manufacturer_data.get(APPLE_MFR_ID))
and apple_data[0] not in APPLE_START_BYTES_WANTED
and not advertisement_data.service_data
(manufacturer_data := service_info.manufacturer_data)
and APPLE_MFR_ID in manufacturer_data
and manufacturer_data[APPLE_MFR_ID][0] not in APPLE_START_BYTES_WANTED
and len(manufacturer_data) == 1
and not service_info.service_data
):
return

device = service_info.device
address = device.address
address = service_info.device.address
all_history = self._all_history
connectable = service_info.connectable
connectable_history = self._connectable_history
old_connectable_service_info = connectable and connectable_history.get(address)

source = service_info.source
# This logic is complex due to the many combinations of scanners
# that are supported.
Expand Down Expand Up @@ -544,13 +541,17 @@ def scanner_adv_received(self, service_info: BluetoothServiceInfoBleak) -> None:
"%s: %s %s match: %s",
self._async_describe_source(service_info),
address,
advertisement_data,
service_info.advertisement,
matched_domains,
)

if connectable or old_connectable_service_info:
if (connectable or old_connectable_service_info) and (
bleak_callbacks := self._bleak_callbacks
):
# Bleak callbacks must get a connectable device
for callback_filters in self._bleak_callbacks:
device = service_info.device
advertisement_data = service_info.advertisement
for callback_filters in bleak_callbacks:
_dispatch_bleak_callback(*callback_filters, device, advertisement_data)

for match in self._callback_index.match_callbacks(service_info):
Expand Down