#Value_template with variable not working.

1 messages · Page 1 of 1 (latest)

mellow rain
#

Variables:
- variables: sensor_entity: "{{ trigger.entity_id }}" room_name: >- {{ sensor_entity | regex_replace('sensor\\.sonde_(.*)_temperature', '\\1') | regex_replace(' ', '_') | replace('temperature', '') | lower }}

Condition:
- if: - condition: template value_template: "{{ states('select.thermostatique_{{room_name}}_sensor') == 'internal' }}" then: - data: entity_id: select.thermostatique_{{room_name}}_sensor option: external action: select.select_option

It seems that value_template doesn't aquire the variable {{room_name}}.

Thanks in advance for the help!

dawn parcel
#

Check the trace of the output of that room_name template outputs what you expect

frail palm
#

You have a nested template (meaning you have double brackets inside double brackets). You can’t do that

#

Instead of {{ states('select.thermostatique_{{room_name}}_sensor') == 'internal' }}

use
{{ states('select.thermostatique_' ~ room_name ~ '_sensor') == 'internal' }}