Use eager task creation for entity platform polling (#111575)

* Use eager task creation for entity platform polling

We have lots of places where `async_update` does not suspend and
is only a coro because its required to be a coro to run in the
event loop

* try again
This commit is contained in:
J. Nick Koston 2024-02-26 18:16:39 -10:00 committed by GitHub
parent 1e02260bbe
commit f56e4d6a09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -624,11 +624,16 @@ class EntityPlatform:
self._async_unsub_polling = async_track_time_interval(
self.hass,
self._update_entity_states,
self._async_handle_interval_callback,
self.scan_interval,
name=f"EntityPlatform poll {self.domain}.{self.platform_name}",
)
@callback
def _async_handle_interval_callback(self, now: datetime) -> None:
"""Update all the entity states in a single platform."""
self.hass.async_create_task(self._update_entity_states(now), eager_start=True)
def _entity_id_already_exists(self, entity_id: str) -> tuple[bool, bool]:
"""Check if an entity_id already exists.