瀏覽代碼

async_refresh: Update any children that are already set up.

async_refresh is still called in a few places, but since it is not via polling
HA does not know to check for entity updates.  Use the same mechanism the
persistent connection loop does to trigger HA to update its cache.

This may allow entities to show some state before startup has finished.  If
it doesn't, we may need to schedule a refresh after all the entities have
registered.
Jason Rumney 3 年之前
父節點
當前提交
5be90c7ca7
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      custom_components/tuya_local/device.py

+ 2 - 0
custom_components/tuya_local/device.py

@@ -300,6 +300,8 @@ class TuyaLocalDevice(object):
         new_state = self._api.status()
         self._cached_state = self._cached_state | new_state["dps"]
         self._cached_state["updated_at"] = time()
+        for entity in self._children:
+            entity.async_schedule_update_ha_state()
         _LOGGER.debug(
             f"{self.name} refreshed device state: {json.dumps(new_state, default=non_json)}",
         )