feat: add support for local expressions in ADExpressionContext and update smart condition handling

This commit is contained in:
2026-06-03 21:52:58 +02:00
parent 943361453a
commit 56e3f6e9e0
3 changed files with 64 additions and 3 deletions

View File

@@ -23,6 +23,10 @@ templates_library:
trigger_conditions: binary_sensor.off == False
blocking_conditions:
- binary_sensor.on
T4:
local_expressions:
local_threshold: "binary_sensor.true ? 170 : 200"
trigger_conditions: sensor.int170 == local_threshold
tests:
test_1:
@@ -44,3 +48,25 @@ tests:
conditions:
template_conditions: <T2>,<T3>
trigger_conditions: binary_sensor.true and binary_sensor.false
# local_expressions in a template
test_5_local_expr_in_template_true:
expected_result: Succeeded
conditions:
template_conditions: <T4>
# local_expressions declared directly in conditions block
test_6_local_expr_inline_true:
expected_result: Succeeded
conditions:
local_expressions:
my_threshold: "binary_sensor.true ? 17 : 200"
trigger_conditions: sensor.int17 == my_threshold
# local_expressions inline, condition not met
test_7_local_expr_inline_false:
expected_result: Failed
conditions:
local_expressions:
my_threshold: "binary_sensor.false ? 17 : 200"
trigger_conditions: sensor.int17 == my_threshold