diff --git a/homeassistant/components/websocket_api/commands.py b/homeassistant/components/websocket_api/commands.py index d4596619241c..c42d48a604e4 100644 --- a/homeassistant/components/websocket_api/commands.py +++ b/homeassistant/components/websocket_api/commands.py @@ -616,8 +616,7 @@ async def handle_test_condition( from homeassistant.helpers import condition # Do static + dynamic validation of the condition - config = cv.CONDITION_SCHEMA(msg["condition"]) - config = await condition.async_validate_condition_config(hass, config) + config = await condition.async_validate_condition_config(hass, msg["condition"]) # Test the condition check_condition = await condition.async_from_config(hass, config) connection.send_result( diff --git a/tests/components/websocket_api/test_commands.py b/tests/components/websocket_api/test_commands.py index 354a4edeb0d6..a5905a809a9e 100644 --- a/tests/components/websocket_api/test_commands.py +++ b/tests/components/websocket_api/test_commands.py @@ -1603,6 +1603,42 @@ async def test_test_condition(hass, websocket_client): assert msg["success"] assert msg["result"]["result"] is True + await websocket_client.send_json( + { + "id": 6, + "type": "test_condition", + "condition": { + "condition": "template", + "value_template": "{{ is_state('hello.world', 'paulus') }}", + }, + "variables": {"hello": "world"}, + } + ) + + msg = await websocket_client.receive_json() + assert msg["id"] == 6 + assert msg["type"] == const.TYPE_RESULT + assert msg["success"] + assert msg["result"]["result"] is True + + await websocket_client.send_json( + { + "id": 7, + "type": "test_condition", + "condition": { + "condition": "template", + "value_template": "{{ is_state('hello.world', 'frenck') }}", + }, + "variables": {"hello": "world"}, + } + ) + + msg = await websocket_client.receive_json() + assert msg["id"] == 7 + assert msg["type"] == const.TYPE_RESULT + assert msg["success"] + assert msg["result"]["result"] is False + async def test_execute_script(hass, websocket_client): """Test testing a condition."""