Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions switchbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ def detection_callback(
advertisement_data: bleak.backends.scanner.AdvertisementData,
) -> None:
"""BTLE adv scan callback."""
_services = list(advertisement_data.service_data.values())
if not _services:
return
_service_data = _services[0]

_device = device.address.replace(":", "").lower()
_service_data = list(advertisement_data.service_data.values())[0]
_model = chr(_service_data[0] & 0b01111111)

supported_types: dict[str, dict[str, Any]] = {
Expand Down Expand Up @@ -153,7 +157,8 @@ async def discover(
devices = None

devices = bleak.BleakScanner(
filters={"UUIDs": [str(_sb_uuid())]},
# TODO: Find new UUIDs to filter on. For example, see
# https://github.com/OpenWonderLabs/SwitchBotAPI-BLE/blob/4ad138bb09f0fbbfa41b152ca327a78c1d0b6ba9/devicetypes/meter.md
adapter=self._interface,
)
devices.register_detection_callback(self.detection_callback)
Expand Down