Explorar o código

Handle invalid basic data

fixes #197
J. Nick Koston %!s(int64=2) %!d(string=hai) anos
pai
achega
809a1bbb5e
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      switchbot/devices/lock.py

+ 4 - 1
switchbot/devices/lock.py

@@ -193,7 +193,10 @@ class SwitchbotLock(SwitchbotDevice):
         # Also update the battery and firmware version
         # Also update the battery and firmware version
         if basic_data := await self._get_basic_info():
         if basic_data := await self._get_basic_info():
             self._last_full_update = time.monotonic()
             self._last_full_update = time.monotonic()
-            self._update_parsed_data(self._parse_basic_data(basic_data))
+            if len(basic_data) >= 3:
+                self._update_parsed_data(self._parse_basic_data(basic_data))
+            else:
+                _LOGGER.warning("Invalid basic data received: %s", basic_data)
             self._fire_callbacks()
             self._fire_callbacks()
 
 
         return status
         return status