From f56e4d6a09790005c5143be33d02aa7ad5e2b5dd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 26 Feb 2024 18:16:39 -1000 Subject: [PATCH] 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 --- homeassistant/helpers/entity_platform.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 6703935c10a..de3d26b1efc 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -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.