From f0c5e00cc1a2b7b5d890c86ad2806ae13d7b9863 Mon Sep 17 00:00:00 2001
From: Artur Pragacz <49985303+arturpragacz@users.noreply.github.com>
Date: Sun, 9 Mar 2025 04:23:24 +0100
Subject: [PATCH] Fix conversation trigger with variables (#140066)

---
 homeassistant/helpers/trigger.py              | 12 ++++++------
 tests/components/conversation/test_trigger.py |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/homeassistant/helpers/trigger.py b/homeassistant/helpers/trigger.py
index 67e9010df79..a27c85a5c58 100644
--- a/homeassistant/helpers/trigger.py
+++ b/homeassistant/helpers/trigger.py
@@ -265,18 +265,18 @@ def _trigger_action_wrapper(
     while isinstance(check_func, functools.partial):
         check_func = check_func.func
 
-    wrapper_func: Callable[..., None] | Callable[..., Coroutine[Any, Any, None]]
+    wrapper_func: Callable[..., Any] | Callable[..., Coroutine[Any, Any, Any]]
     if asyncio.iscoroutinefunction(check_func):
-        async_action = cast(Callable[..., Coroutine[Any, Any, None]], action)
+        async_action = cast(Callable[..., Coroutine[Any, Any, Any]], action)
 
         @functools.wraps(async_action)
         async def async_with_vars(
             run_variables: dict[str, Any], context: Context | None = None
-        ) -> None:
+        ) -> Any:
             """Wrap action with extra vars."""
             trigger_variables = conf[CONF_VARIABLES]
             run_variables.update(trigger_variables.async_render(hass, run_variables))
-            await action(run_variables, context)
+            return await action(run_variables, context)
 
         wrapper_func = async_with_vars
 
@@ -285,11 +285,11 @@ def _trigger_action_wrapper(
         @functools.wraps(action)
         async def with_vars(
             run_variables: dict[str, Any], context: Context | None = None
-        ) -> None:
+        ) -> Any:
             """Wrap action with extra vars."""
             trigger_variables = conf[CONF_VARIABLES]
             run_variables.update(trigger_variables.async_render(hass, run_variables))
-            action(run_variables, context)
+            return action(run_variables, context)
 
         if is_callback(check_func):
             with_vars = callback(with_vars)
diff --git a/tests/components/conversation/test_trigger.py b/tests/components/conversation/test_trigger.py
index 3aa8ae2939f..a01f4cd8112 100644
--- a/tests/components/conversation/test_trigger.py
+++ b/tests/components/conversation/test_trigger.py
@@ -104,6 +104,7 @@ async def test_response(hass: HomeAssistant) -> None:
                 "trigger": {
                     "platform": "conversation",
                     "command": ["Open the pod bay door Hal"],
+                    "variables": {"name": "Dr. David Bowman"},
                 },
                 "action": {
                     "set_conversation_response": response,
-- 
GitLab