mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Fix conversation trigger with variables (#140066)
This commit is contained in:
parent
ffcc0496f1
commit
f0c5e00cc1
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user