Просмотр исходного кода

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 лет назад
Родитель
Сommit
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):
         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(