We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent feec093 commit 0a00bc8Copy full SHA for 0a00bc8
switchbot/__init__.py
@@ -21,7 +21,6 @@ class Switchbot:
21
def __init__(self, mac) -> None:
22
self._mac = mac
23
self._device = None
24
- self._connect()
25
26
def _connect(self) -> bool:
27
if self._device is not None:
@@ -40,6 +39,10 @@ def _connect(self) -> bool:
40
39
return True
41
42
def _sendpacket(self, key, retry=2) -> bool:
+ if self._device is None and not self._connect():
43
+ _LOGGER.error("Cannot connect to switchbot.")
44
+ return False
45
+
46
try:
47
_LOGGER.debug("Prepare to send")
48
hand_service = self._device.getServiceByUUID(UUID)
0 commit comments