From dcab766cef997778a3c1b81f10b32437ac6c500c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 22 Feb 2023 03:35:05 +0100 Subject: [PATCH] Only scan for the configured Bluetooth service UUIDs. --- platypush/plugins/bluetooth/ble/__init__.py | 2 +- platypush/plugins/switchbot/bluetooth/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platypush/plugins/bluetooth/ble/__init__.py b/platypush/plugins/bluetooth/ble/__init__.py index 014996779f..4bc4391c30 100644 --- a/platypush/plugins/bluetooth/ble/__init__.py +++ b/platypush/plugins/bluetooth/ble/__init__.py @@ -496,7 +496,7 @@ class BluetoothBlePlugin(AsyncRunnablePlugin, EntityManager): while True: await self._scan_enabled.wait() - entities = await self._scan() + entities = await self._scan(uuids=self._uuids) new_device_addresses = {e.external_id for e in entities} missing_device_addresses = device_addresses - new_device_addresses diff --git a/platypush/plugins/switchbot/bluetooth/__init__.py b/platypush/plugins/switchbot/bluetooth/__init__.py index 7a920a7fe2..de4e5a9650 100644 --- a/platypush/plugins/switchbot/bluetooth/__init__.py +++ b/platypush/plugins/switchbot/bluetooth/__init__.py @@ -48,19 +48,19 @@ class SwitchbotBluetoothPlugin(BluetoothBlePlugin, EnumSwitchEntityManager): # Static list of Bluetooth service UUIDs commonly exposed by SwitchBot # devices. - _uuids = { + _service_uuids = { service: UUID(f'cba20{prefix}-224d-11e6-9fb8-0002a5d5c51b') for service, prefix in _uuid_prefixes.items() } def __init__(self, *args, **kwargs): - super().__init__(*args, characteristics=self._uuids.values(), **kwargs) + super().__init__(*args, uuids=self._service_uuids.values(), **kwargs) async def _run( self, device: str, command: Command, - service_uuid: UUIDType = _uuids['tx'], + service_uuid: UUIDType = _service_uuids['tx'], ): await self._write(device, command.value, service_uuid)