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

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