From 6b5bbede526b3eee3486ea2e9238034cb46b70ce Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 24 Apr 2026 12:25:39 +0200 Subject: [PATCH] Update websocket_api.handle_test_condition to use modern condition API (#169029) --- homeassistant/components/websocket_api/commands.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/websocket_api/commands.py b/homeassistant/components/websocket_api/commands.py index b99e86511218..85725361bcf2 100644 --- a/homeassistant/components/websocket_api/commands.py +++ b/homeassistant/components/websocket_api/commands.py @@ -1028,10 +1028,13 @@ async def handle_test_condition( # Do static + dynamic validation of the condition config = await async_validate_condition_config(hass, msg["condition"]) # Test the condition - check_condition = await async_condition_from_config(hass, config) - connection.send_result( - msg["id"], {"result": check_condition(hass, msg.get("variables"))} - ) + condition = await async_condition_from_config(hass, config) + try: + connection.send_result( + msg["id"], {"result": condition.async_check(variables=msg.get("variables"))} + ) + finally: + condition.async_unload() @decorators.websocket_command(