frankiep
(Francesco Paradiso)
January 31, 2024, 8:11am
1
Hi there!
i need to create a template sensor with some “if states” that, in some of those, returns the value of another sensor.
I tried so:
pdc_temperatura_mandata_acs_template:
value_template: >-
{% if states('sensor.pdc_stato') == '4' %}
sensor.pdc_temperatura_mandata
{% else %}
-
{% endif %}
but it returns the text “sensor.pdc_temperatura_mandata” and it’s wrong.
But i need when if “sensor.pdc_stato” = 4 the template returns the “sensor.pdc_temperatura_mandata” value.
thanks
tom_l
January 31, 2024, 8:22am
2
pdc_temperatura_mandata_acs_template:
value_template: >-
{% if states('sensor.pdc_stato') == '4' %}
{{ states('sensor.pdc_temperatura_mandata') }}
{% else %}
-
{% endif %}
1 Like
Troon
(Troon)
January 31, 2024, 8:28am
3
frankiep:
value_template:
If you’re just starting to write YAML template sensors, you should be using the modern configuration instead:
template:
- sensor:
- name: "PDC temperatura mandata acs template"
state:
rather than
sensor:
- platform: template
sensors:
pdc_temperatura_mandata_acs_template:
value_template:
See here:
1 Like