Only scan for the configured Bluetooth service UUIDs.

This commit is contained in:
Fabio Manganiello 2023-02-22 03:35:05 +01:00
parent d8c429f4a8
commit dcab766cef
Signed by: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 4 additions and 4 deletions

View file

@ -496,7 +496,7 @@ class BluetoothBlePlugin(AsyncRunnablePlugin, EntityManager):
while True: while True:
await self._scan_enabled.wait() 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} new_device_addresses = {e.external_id for e in entities}
missing_device_addresses = device_addresses - new_device_addresses missing_device_addresses = device_addresses - new_device_addresses

View file

@ -48,19 +48,19 @@ class SwitchbotBluetoothPlugin(BluetoothBlePlugin, EnumSwitchEntityManager):
# Static list of Bluetooth service UUIDs commonly exposed by SwitchBot # Static list of Bluetooth service UUIDs commonly exposed by SwitchBot
# devices. # devices.
_uuids = { _service_uuids = {
service: UUID(f'cba20{prefix}-224d-11e6-9fb8-0002a5d5c51b') service: UUID(f'cba20{prefix}-224d-11e6-9fb8-0002a5d5c51b')
for service, prefix in _uuid_prefixes.items() for service, prefix in _uuid_prefixes.items()
} }
def __init__(self, *args, **kwargs): 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( async def _run(
self, self,
device: str, device: str,
command: Command, command: Command,
service_uuid: UUIDType = _uuids['tx'], service_uuid: UUIDType = _service_uuids['tx'],
): ):
await self._write(device, command.value, service_uuid) await self._write(device, command.value, service_uuid)