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:
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

View file

@ -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)