I’ve spent a lot of time and getting no where… anyone have an example of how to use Condition Selector … I need it to be ‘dynamically evaluated’ after the trigger occurs. It seems that I cannot find a way to either return a Boolean (HA does the processing on-the-fly and returns true/false to the automation) or get the conditions to do in-place evaluation in the YAML.
one of many methods I’ve tried…
- choose:
# Path 1: No additional conditions (empty) - Profile passes
- conditions:
- condition: template
value_template: >
{% if condition_1_entity_condition is defined and condition_1_entity_condition %}
{% if condition_1_entity_condition is string %}
{{ condition_1_entity_condition == '[]' or condition_1_entity_condition == '' }}
{% elif condition_1_entity_condition is iterable %}
{{ condition_1_entity_condition|length == 0 }}
{% else %}
false
{% endif %}
{% else %}
true
{% endif %}
sequence:
# All checks passed - set Profile 1
- variables:
current_profile: 1
active_time_delay: "{{ condition_1_time_delay }}"
active_brightness: "{{ condition_1_brightness }}"
# Path 2: Additional conditions exist - evaluate them with choose/if
- conditions:
- condition: template
value_template: >
{% if condition_1_entity_condition is defined and condition_1_entity_condition %}
{% if condition_1_entity_condition is string %}
{{ condition_1_entity_condition != '[]' and condition_1_entity_condition != '' }}
{% elif condition_1_entity_condition is iterable %}
{{ condition_1_entity_condition|length > 0 }}
{% else %}
true
{% endif %}
{% else %}
false
{% endif %}
sequence:
# Use choose to evaluate the dynamic conditions
- choose:
- conditions: "{{ condition_1_entity_condition }}"
sequence:
# Additional conditions passed - set Profile 1
- variables:
current_profile: 1
active_time_delay: "{{ condition_1_time_delay }}"
active_brightness: "{{ condition_1_brightness }}"