ソースを参照

fix: reject advertisement updates that are missing data if we already have it (#93)

J. Nick Koston 2 年 前
コミット
1ebcc8cabe
1 ファイル変更4 行追加1 行削除
  1. 4 1
      switchbot/devices/device.py

+ 4 - 1
switchbot/devices/device.py

@@ -357,7 +357,10 @@ class SwitchbotDevice:
 
     def update_from_advertisement(self, advertisement: SwitchBotAdvertisement) -> None:
         """Update device data from advertisement."""
-        self._sb_adv_data = advertisement
+        # Only accept advertisements if the data is not missing
+        # if we already have an advertisement with data
+        if advertisement.data.get("data") or not self._sb_adv_data.data.get("data"):
+            self._sb_adv_data = advertisement
         self._override_adv_data = None
         if self._device and ble_device_has_changed(self._device, advertisement.device):
             self._cached_services = None