فهرست منبع

Do not clobber old dps when updating.

Many devices only seem to return partial data for each update.
To avoid reporting attributes as missing, keep the old data when a partial
update comes through.

May help with #92, #137 and other issues with strange behaviour.
Jason Rumney 3 سال پیش
والد
کامیت
525ca88382
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      custom_components/tuya_local/device.py

+ 1 - 1
custom_components/tuya_local/device.py

@@ -166,7 +166,7 @@ class TuyaLocalDevice(object):
 
 
     def _refresh_cached_state(self):
     def _refresh_cached_state(self):
         new_state = self._api.status()
         new_state = self._api.status()
-        self._cached_state = new_state["dps"]
+        self._cached_state = self._cached_state | new_state["dps"]
         self._cached_state["updated_at"] = time()
         self._cached_state["updated_at"] = time()
         _LOGGER.debug(f"{self.name} refreshed device state: {json.dumps(new_state)}")
         _LOGGER.debug(f"{self.name} refreshed device state: {json.dumps(new_state)}")
         _LOGGER.debug(
         _LOGGER.debug(