From b353835ce524c34ff1f785e4fca7ea3dd1bc3e1c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 14 Mar 2024 08:54:58 -1000 Subject: [PATCH] Add blog post about deprecation of async_add_job and async_run_job (#2111) --- blog/2024-03-13-deprecate_add_run_job.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 blog/2024-03-13-deprecate_add_run_job.md diff --git a/blog/2024-03-13-deprecate_add_run_job.md b/blog/2024-03-13-deprecate_add_run_job.md new file mode 100644 index 00000000..cc84ddb8 --- /dev/null +++ b/blog/2024-03-13-deprecate_add_run_job.md @@ -0,0 +1,18 @@ +--- +author: J. Nick Koston +authorURL: https://github.com/bdraco +title: "Deprecating `async_run_job` and `async_add_job`" +--- + +`async_run_job` and `async_add_job` are deprecated and will be removed in Home Assistant 2025.4. This deprecation does not apply to the sync API `add_job` method, which is not planned to be removed. + +Instead, it's more efficient to use one of the other job methods, as the method of calling the job does not ever have to be worked out: + +If the callable is a coroutine function running from a config entry: +`entry.async_create_background_task`, `entry.async_create_task` + +If the callable is a coroutine function running from another place: +`hass.async_create_background_task`, `hass.async_create_task` + +If the callable should run in the executor: +`hass.async_add_executor_job`