소스 검색

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)}",
         )