Browse Source

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 năm trước cách đây
mục cha
commit
525ca88382
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  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):
         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()
         _LOGGER.debug(f"{self.name} refreshed device state: {json.dumps(new_state)}")
         _LOGGER.debug(