Browse Source

Improve logging to show hex values for easier debugging (#123)

J. Nick Koston 6 days ago
parent
commit
dd18d67902
2 changed files with 10 additions and 11 deletions
  1. 8 2
      switchbot/devices/bot.py
  2. 2 9
      switchbot/devices/device.py

+ 8 - 2
switchbot/devices/bot.py

@@ -40,7 +40,10 @@ class Switchbot(SwitchbotDeviceOverrideStateDuringConnection):
         ret = self._check_command_result(result, 0, {1, 5})
         self._override_adv_data = {"isOn": True}
         _LOGGER.debug(
-            "%s: Turn on result: %s -> %s", self.name, result, self._override_adv_data
+            "%s: Turn on result: %s -> %s",
+            self.name,
+            result.hex() if result else None,
+            self._override_adv_data,
         )
         self._fire_callbacks()
         return ret
@@ -51,7 +54,10 @@ class Switchbot(SwitchbotDeviceOverrideStateDuringConnection):
         ret = self._check_command_result(result, 0, {1, 5})
         self._override_adv_data = {"isOn": False}
         _LOGGER.debug(
-            "%s: Turn off result: %s -> %s", self.name, result, self._override_adv_data
+            "%s: Turn off result: %s -> %s",
+            self.name,
+            result.hex() if result else None,
+            self._override_adv_data,
         )
         self._fire_callbacks()
         return ret

+ 2 - 9
switchbot/devices/device.py

@@ -131,14 +131,7 @@ class SwitchbotBaseDevice:
         if retry is None:
             retry = self._retry_count
         command = bytearray.fromhex(self._commandkey(key))
-        _LOGGER.debug("%s: Sending command %s", self.name, command)
-        if self._operation_lock.locked():
-            _LOGGER.debug(
-                "%s: Operation already in progress, waiting for it to complete; RSSI: %s",
-                self.name,
-                self.rssi,
-            )
-
+        _LOGGER.debug("%s: Scheduling command %s", self.name, command.hex())
         max_attempts = retry + 1
         if self._operation_lock.locked():
             _LOGGER.debug(
@@ -359,7 +352,7 @@ class SwitchbotBaseDevice:
 
         async with async_timeout.timeout(5):
             notify_msg = await self._notify_future
-        _LOGGER.debug("%s: Notification received: %s", self.name, notify_msg)
+        _LOGGER.debug("%s: Notification received: %s", self.name, notify_msg.hex())
         self._notify_future = None
 
         if notify_msg == b"\x07":