Need some help understanding how to use a script field value in a conditional. What I’m trying to do is pass in a zwave sensor entity and check that it’s node_name attribute matches a string before setting zwave configuration parameters.
In the script below I have a field called entity_id, I am then creating a variables called entity and trying to use it in a value_template. I get a configuration error. How do I properly use this field in the value_template?
The error is
invalid key: "OrderedDict([("states(entity).attributes.node_name == 'AEON Labs ZW100 MultiSensor 6'", None)])"
in "/config/scripts.yaml", line 85, column 0
Line 85 is the value_template line below.
Similarily, I will need to find a way to get the .node_id attribute of the entity and use that where I have {{node_id}}
So two problems, hopefully with similar solutions.
configure_aoetec_multisensor_node:
alias: configure_aoetec_multisensor
description: 'Configures / reconfigures the AOETec Mulitsensor'
fields:
entity_id:
description: 'Entity Id'
example: 'zwave.sensor_2'
mode: single
variables:
entity: "{{ entity_id }}"
sequence:
- service: system_log.write
data:
message: "Before Test"
- condition:
condition: template
value_template: {{ states(entity).attributes.node_name == 'AEON Labs ZW100 MultiSensor 6' }}
- service: system_log.write
data:
message: "After Test"
# https://products.z-wavealliance.org/products/2684/configs
- service: zwave.set_config_parameter
data:
# Temp, Humidity, Luminance
node_id: "{{ node_id }}"
parameter: 101
value: 224
size: 4
- service: zwave.set_config_parameter
data:
# Report interval
node_id: "{{ node_id }}"
parameter: 111
value: 240
size: 4
- service: zwave.set_config_parameter
data:
# No report on threshold
node_id: "{{ node_id }}"
parameter: 40
value: Disabled
size: 1
- service: zwave.set_config_parameter
data:
# Disable motion sensor for now.
node_id: "{{ node_id }}"
parameter: 4
value: Disabled
size: 1