mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
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:
parent
1e02260bbe
commit
f56e4d6a09
@ -624,11 +624,16 @@ class EntityPlatform:
|
|||||||
|
|
||||||
self._async_unsub_polling = async_track_time_interval(
|
self._async_unsub_polling = async_track_time_interval(
|
||||||
self.hass,
|
self.hass,
|
||||||
self._update_entity_states,
|
self._async_handle_interval_callback,
|
||||||
self.scan_interval,
|
self.scan_interval,
|
||||||
name=f"EntityPlatform poll {self.domain}.{self.platform_name}",
|
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]:
|
def _entity_id_already_exists(self, entity_id: str) -> tuple[bool, bool]:
|
||||||
"""Check if an entity_id already exists.
|
"""Check if an entity_id already exists.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user