2 Commits f5e5f77a4c ... e2d9b046b8

Author SHA1 Message Date
  J. Nick Koston e2d9b046b8 0.19.10 6 days ago
  J. Nick Koston dd18d67902 Improve logging to show hex values for easier debugging (#123) 6 days ago
3 changed files with 11 additions and 12 deletions
  1. 1 1
      setup.py
  2. 8 2
      switchbot/devices/bot.py
  3. 2 9
      switchbot/devices/device.py

+ 1 - 1
setup.py

@@ -4,7 +4,7 @@ setup(
     name="PySwitchbot",
     packages=["switchbot", "switchbot.devices", "switchbot.adv_parsers"],
     install_requires=["async_timeout>=4.0.1", "bleak>=0.17.0", "bleak-retry-connector>=1.17.1"],
-    version="0.19.9",
+    version="0.19.10",
     description="A library to communicate with Switchbot",
     author="Daniel Hjelseth Hoyer",
     url="https://github.com/Danielhiversen/pySwitchbot/",

+ 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":