Skip to content

Commit aaee4d3

Browse files
moreteaMaarten Hoogendoorn
andauthored
feature: Enable choice of bluetooth interface in the host (#15)
Co-authored-by: Maarten Hoogendoorn <[email protected]>
1 parent f09079f commit aaee4d3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

switchbot/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class SwitchbotDevice:
3434
# pylint: disable=too-few-public-methods
3535
"""Base Representation of a Switchbot Device."""
3636

37-
def __init__(self, mac, retry_count=DEFAULT_RETRY_COUNT, password=None) -> None:
37+
def __init__(self, mac, retry_count=DEFAULT_RETRY_COUNT, password=None, interface=None) -> None:
38+
self._interface = interface
3839
self._mac = mac
3940
self._device = None
4041
self._retry_count = retry_count
@@ -49,7 +50,8 @@ def _connect(self) -> None:
4950
try:
5051
_LOGGER.debug("Connecting to Switchbot...")
5152
self._device = bluepy.btle.Peripheral(self._mac,
52-
bluepy.btle.ADDR_TYPE_RANDOM)
53+
bluepy.btle.ADDR_TYPE_RANDOM,
54+
self._interface)
5355
_LOGGER.debug("Connected to Switchbot.")
5456
except bluepy.btle.BTLEException:
5557
_LOGGER.debug("Failed connecting to Switchbot.", exc_info=True)

0 commit comments

Comments
 (0)