Browse Source

fix: add a guard to the bulb to reject invalid state updates (#86)

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

+ 2 - 0
switchbot/devices/bulb.py

@@ -131,6 +131,8 @@ class SwitchbotBulb(SwitchbotDevice):
 
     def _update_state(self, result: bytes) -> None:
         """Update device state."""
+        if len(result) < 10:
+            return
         self._state["r"] = result[3]
         self._state["g"] = result[4]
         self._state["b"] = result[5]