瀏覽代碼

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

J. Nick Koston 2 年之前
父節點
當前提交
f19fd1cad2
共有 1 個文件被更改,包括 2 次插入0 次删除
  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]