Hi
for my electric-floor-heating automation I need a template which returns the entity with the biggest temperature difference between temperature and current_temperature of a list of climate entities.
Maybe 4 out of 6 entities have the attribute hvac_action = heating, but I want to activate the heating zone where there is the biggest temperature difference.
the reason for this is that the 6 contactors in the control panel are interlocked against each other, otherwise the current consumption becomes too large.
I think there must be a better way than my template, or at least a better syntax:
{%- set return = namespace(return=false) -%}
{%- set ns = namespace(big_temp_diff=0) -%}
{%- for clim in ['climate.flur', 'climate.gastezimmer', 'climate.schlafzimmer', 'climate.buro', 'climate.badezimmer', 'climate.wohnzimmer_kuche'] | select('is_state', 'heat') | select('is_state_attr', 'hvac_action', 'heating') -%}
{% set this_temp_diff = state_attr(clim, 'temperature') - state_attr(clim, 'current_temperature') %}
{% if this_temp_diff > ns.big_temp_diff %}
{%- set ns.big_temp_diff = this_temp_diff -%}
{% set return.return = clim %}
{%- endif -%}
#debug {{ clim }} = {{ this_temp_diff }}
{%- endfor %}
Return: {{ return.return }} is the climate entity with the biggest temperature difference with {{ ns.big_temp_diff }} °C
Output in template-editor:
#climate.flur = 1.5
#climate.badezimmer = 6.5
#climate.wohnzimmer_kuche = 4.0
Return: climate.badezimmer is the climate entity with the biggest temperature difference with 6.5 °C