mirror of
https://github.com/home-assistant/core.git
synced 2026-09-30 02:45:43 +01:00
Update websocket_api.handle_test_condition to use modern condition API (#169029)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user