diff --git a/homeassistant/components/bluetooth/models.py b/homeassistant/components/bluetooth/models.py index 43d4d0cb923..eda94305aa9 100644 --- a/homeassistant/components/bluetooth/models.py +++ b/homeassistant/components/bluetooth/models.py @@ -113,9 +113,10 @@ class HaBleakScannerWrapper(BaseBleakScanner): # type: ignore[misc] """Map the filters.""" mapped_filters = {} if filters := kwargs.get("filters"): - if FILTER_UUIDS not in filters: + if filter_uuids := filters.get(FILTER_UUIDS): + mapped_filters[FILTER_UUIDS] = set(filter_uuids) + else: _LOGGER.warning("Only %s filters are supported", FILTER_UUIDS) - mapped_filters = {k: set(v) for k, v in filters.items()} if service_uuids := kwargs.get("service_uuids"): mapped_filters[FILTER_UUIDS] = set(service_uuids) if mapped_filters == self._mapped_filters: diff --git a/tests/components/bluetooth/test_init.py b/tests/components/bluetooth/test_init.py index 1d348f42f0e..ec737cef593 100644 --- a/tests/components/bluetooth/test_init.py +++ b/tests/components/bluetooth/test_init.py @@ -686,6 +686,9 @@ async def test_wrapped_instance_unsupported_filter( assert models.HA_BLEAK_SCANNER is not None scanner = models.HaBleakScannerWrapper() scanner.set_scanning_filter( - filters={"unsupported": ["cba20d00-224d-11e6-9fb8-0002a5d5c51b"]} + filters={ + "unsupported": ["cba20d00-224d-11e6-9fb8-0002a5d5c51b"], + "DuplicateData": True, + } ) assert "Only UUIDs filters are supported" in caplog.text