Hi, thanks for all the good ideas. I’m trying to adapt it a bit to my own situation, so I added this to sensor.yaml:
#sensor virtual CV setpoint
- platform: template
sensors:
setpoint_cv_virtual:
friendly_name: "CV Virtual Setpoint"
unit_of_measurement: "°C"
value_template: >
{% set baby_td = (state_attr('climate.baby','temperature') - states('sensor.babykamer_temphum_temperature') | float) %}
{% set work_td = (state_attr('climate.work','temperature') - states('sensor.werkkamer_temphum_temperature') | float)%}
{% set living_td = (state_attr('climate.living','temperature') - states('sensor.temphum_sensor1_temperature') | float) %}
{% set bath_td = (state_attr('climate.bath','temperature') - states('sensor.badkamer_sensor_temperature') | float) %}
{% set max_td = ([living_td,baby_td,work_td,bath_td] | max) %}
{% set list_room_td = [living_td,baby_td,work_td,bath_td] %}
{% set index_td = list_room_td.index(max_td) %}
{% if index_td == 1 %}
{{ state_attr('climate.baby','temperature') }}
{% elif index_td == 2 %}
{{ state_attr('climate.work','temperature') }}
{% elif %}
{{ state_attr('climate.living','temperature') }}
{% else %}
{{ state_attr('climate.bath','temperature') }}
{% endif %}
temperature_cv_virtual:
friendly_name: "CV Virtual Temperature"
unit_of_measurement: "°C"
value_template: >
{% set baby_td = (state_attr('climate.baby','temperature') - states('sensor.babykamer_temphum_temperature') | float) %}
{% set work_td = (state_attr('climate.work','temperature') - states('sensor.werkkamer_temphum_temperature') | float)%}
{% set living_td = (state_attr('climate.living','temperature') - states('sensor.temphum_sensor1_temperature') | float) %}
{% set bath_td = (state_attr('climate.bath','temperature') - states('sensor.badkamer_sensor_temperature') | float) %}
{% set max_td = ([living_td,baby_td,work_td,bath_td] | max) %}
{% set list_room_td = [living_td,baby_td,work_td,bath_td] %}
{% set index_td = list_room_td.index(max_td) %}
{% if index_td == 1 %}
{{ states('sensor.babykamer_temphum_temperature') | float }}
{% elif index_td == 2 %}
{{ states('sensor.werkkamer_temphum_temperature') | float }}
{% elif %}
{{ states('sensor.temphum_sensor1_temperature') | float }}
{% else %}
{{ states('sensor.badkamer_sensor_temperature') | float }}
{% endif %}
#end
Then I got this back. Any ideas?
Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: Expected an expression, got ‘end of statement block’) for dictionary value @ data[‘sensors’][‘setpoint_cv_virtual’][‘value_template’]. Got "{% set baby_td = (state_attr(‘climate.baby’,‘temperature’) - states(‘sensor.babykamer_temphum_temperature’) | float) %} {% set work_td = (state_attr(‘climate.work’,‘temperature’) - states(‘sensor.werkkamer_temphum_temperature’) | float)%} {% set living_td = (state_attr(‘climate.living’,‘temperature’) - states(‘sensor.temphum_sensor1_temperature’) | float) %} {% set bath_td = (state_attr(‘climate.bath’,‘temperature’) - states(‘sensor.badkamer_sensor_temperature’) | float) %} {% set max_td = (…
invalid template (TemplateSyntaxError: Expected an expression, got ‘end of statement block’) for dictionary value @ data[‘sensors’][‘temperature_cv_virtual’][‘value_template’]. Got "{% set baby_td = (state_attr(‘climate.baby’,‘temperature’) - states(‘sensor.babykamer_temphum_temperature’) | float) %} {% set work_td = (state_attr(‘climate.work’,‘temperature’) - states(‘sensor.werkkamer_temphum_temperature’) | float)%} {% set living_td = (state_attr(‘climate.living’,‘temperature’) - states(‘sensor.temphum_sensor1_temperature’) | float) %} {% set bath_td = (state_attr(‘climate.bath’,‘temperature’) - states(‘sensor.badkamer_sensor_temperature’) | float) %} {% set max_td = (… (See ?, line ?).