Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
5be90c7ca7
1 muutettua tiedostoa jossa 2 lisäystä ja 0 poistoa
  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)}",
         )