Explorar o código

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 %!s(int64=3) %!d(string=hai) anos
pai
achega
525ca88382
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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(