Skip to content

Commit 08146ff

Browse files
More logging
1 parent 51b43c2 commit 08146ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

switchbot/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ def __init__(self, mac) -> None:
2121

2222
def _sendpacket(self, key, retry=2) -> bool:
2323
try:
24+
_LOGGER.debug("Connecting")
2425
device = bluepy.btle.Peripheral(self._mac,
2526
bluepy.btle.ADDR_TYPE_RANDOM)
2627
hand_service = device.getServiceByUUID(UUID)
2728
hand = hand_service.getCharacteristics(HANDLE)[0]
29+
_LOGGER.debug("Sending command, %s", key)
2830
hand.write(binascii.a2b_hex(key))
31+
_LOGGER.debug("Disconnecting")
2932
device.disconnect()
3033
except bluepy.btle.BTLEException:
31-
_LOGGER.error("Cannot connect to switchbot.", exc_info=True)
34+
_LOGGER.error("Cannot connect to switchbot. Retrying", exc_info=True)
3235
if retry < 1:
36+
_LOGGER.error("Cannot connect to switchbot.", exc_info=True)
3337
return False
3438
return self._sendpacket(key, retry-1)
3539
return True

0 commit comments

Comments
 (0)