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
5 changes: 4 additions & 1 deletion switchbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Switchbot:
def __init__(self, mac) -> None:
self._mac = mac
self._device = None
self._connect()

def _connect(self) -> bool:
if self._device is not None:
Expand All @@ -40,6 +39,10 @@ def _connect(self) -> bool:
return True

def _sendpacket(self, key, retry=2) -> bool:
if self._device is None and not self._connect():
_LOGGER.error("Cannot connect to switchbot.")
return False

try:
_LOGGER.debug("Prepare to send")
hand_service = self._device.getServiceByUUID(UUID)
Expand Down