Browse Source

Improve logging of failed operations (#95)

J. Nick Koston 2 years ago
parent
commit
e248b30429
1 changed files with 2 additions and 1 deletions
  1. 2 1
      switchbot/devices/device.py

+ 2 - 1
switchbot/devices/device.py

@@ -423,8 +423,9 @@ class SwitchbotDevice:
     ) -> bool:
     ) -> bool:
         """Check command result."""
         """Check command result."""
         if not result or len(result) - 1 < index:
         if not result or len(result) - 1 < index:
+            result_hex = result.hex() if result else "None"
             raise SwitchbotOperationError(
             raise SwitchbotOperationError(
-                f"{self.name}: Sending command failed (rssi={self.rssi})"
+                f"{self.name}: Sending command failed (result={result_hex} index={index} expected={values} rssi={self.rssi})"
             )
             )
         return result[index] in values
         return result[index] in values