Hi there,
Very new to YAML and home assistant in general, so please bear with me.
I’m trying to execute a choose command in a blueprint with condition:
# reset helpers when switch turns off
- choose:
- conditions:
- condition: >
{{target_switch.trigger.to_state.state == "off"}}
target_switch is defined as follows:
input:
motion_sensor:
name: Motion Sensor
description: link to motion sensor
selector:
entity:
filter:
- domain: binary_sensor
- device_class: motion
target_switch:
name: Switch
description: link to switch to be used
selector:
target:
entity:
- domain: switch
When i try to make an automation based on this blueprint, i get the following error:
"Message malformed: Unexpected value for condition: '{{target_switch.trigger.to_state.state == "off"}} '. Expected and, device, not, numeric_state, or, state, sun, template, time, trigger, zone @ data['actions'][0]['choose'][0]['conditions'][0]"
what am i doing wrong?
Thanks in advance for anyone taking a look at this!
Full code for context:
blueprint:
name: Motion Light Tutorial
description: Turn a light on based on detected motion
domain: automation
homeassistant:
min_version: 2024.6.0
input:
motion_sensor:
name: Motion Sensor
description: link to motion sensor
selector:
entity:
filter:
- domain: binary_sensor
- device_class: motion
target_switch:
name: Switch
description: link to switch to be used
selector:
target:
entity:
- domain: switch
helper_man:
name: Helper Manual
description: Boolean helper to determine manual operation
selector:
entity:
filter:
- domain: input_boolean
helper_auto:
name: Helper Automatic
description: Boolean helper to determine automatic operation
selector:
entity:
filter:
- domain: input_boolean
triggers:
- trigger: state
entity_id: !input motion_sensor
- trigger: state
entity_id: !input target_switch
- trigger: state
entity_id: !input motion_sensor
to: "off"
for:
seconds: 30
minutes: 0
actions:
# reset helpers when switch turns off
- choose:
- conditions:
- condition: >
{{target_switch.trigger.to_state.state == "off"}}
sequence:
- action: input_boolean.turn_off
target:
entity_id: !input helper_auto
- action: input_boolean.turn_off
target:
entity_id: !input helper_man
# when motion gets triggered and no manual override
- choose:
- conditions:
- condition: >
{{motion_sensor.trigger.to_state.state == "on" & helper_man == "off"}}
sequence:
- action: input_boolean.turn_on
target:
entity_id: !input helper_auto
- action: switch.turn_on
target:
entity_id: !input target_switch
# when no motion and no manual override
- choose:
- conditions:
- condition: >
{{motion_sensor.trigger.to_state.state == "off" & helper_man == "off"}}
sequence:
- action: switch.turn_off
target:
entity_id: !input target_switch
- action: input_boolean.turn_off
target:
entity_id: !input helper_man
- action: input_boolean.turn_off
target:
entity_id: !input helper_auto
# when switch is set to on manually, turn on override
- choose:
- conditions:
- condition: >
{{target_switch.trigger.to_state.state == "on" & helper_auto == "off"}}
sequence:
- action: input_boolean.turn_on
target:
entity_id: !input helper_man
#if 30 minutes has passed (third trigger), turn off manual override and turn off switch
- choose:
- conditions:
- condition: >
{{target_switch == "on" & helper_man == "on"}}
sequence:
- action: input_boolean.turn_off
target:
entity_id: !input helper_man
- action: input_boolean.turn_off
target:
entity_id: !input helper_auto
- action: switch.turn_off
target:
entity_id: !input target_switch