For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /developers/blog/2024-03-13-deprecate_add_run_job.md.

弃用 async_run_jobasync_add_job

async_run_jobasync_add_job 已被弃用,并将在 Home Assistant 2025.4 中移除。此弃用不适用于 sync API add_job 方法,该方法计划保留不移除。

转而使用其他 job 方法更高效,因为不需要去判断 job 的调用方式:

如果 callable 是从 config entry 运行的 coroutine 函数: entry.async_create_background_taskentry.async_create_task

如果 callable 是从其他位置运行的 coroutine 函数: hass.async_create_background_taskhass.async_create_task

如果 callable 应该在 executor 中运行: hass.async_add_executor_job