Avoid throwing on unsupported bleak client filter (#75378)
* Avoid throwing on unsupported bleak client filter * Avoid throwing on unsupported bleak client filter
This commit is contained in:
parent
939c33b1dc
commit
a95c2c7850
2 changed files with 7 additions and 3 deletions
|
@ -113,9 +113,10 @@ class HaBleakScannerWrapper(BaseBleakScanner): # type: ignore[misc]
|
||||||
"""Map the filters."""
|
"""Map the filters."""
|
||||||
mapped_filters = {}
|
mapped_filters = {}
|
||||||
if filters := kwargs.get("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)
|
_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"):
|
if service_uuids := kwargs.get("service_uuids"):
|
||||||
mapped_filters[FILTER_UUIDS] = set(service_uuids)
|
mapped_filters[FILTER_UUIDS] = set(service_uuids)
|
||||||
if mapped_filters == self._mapped_filters:
|
if mapped_filters == self._mapped_filters:
|
||||||
|
|
|
@ -686,6 +686,9 @@ async def test_wrapped_instance_unsupported_filter(
|
||||||
assert models.HA_BLEAK_SCANNER is not None
|
assert models.HA_BLEAK_SCANNER is not None
|
||||||
scanner = models.HaBleakScannerWrapper()
|
scanner = models.HaBleakScannerWrapper()
|
||||||
scanner.set_scanning_filter(
|
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
|
assert "Only UUIDs filters are supported" in caplog.text
|
||||||
|
|
Loading…
Add table
Reference in a new issue