Custom sensor error with climate entity

I am trying to create a sensor that will simply tell me if any of my tado radiator valves are set to ‘heat’ rather than ‘auto’. This code always give the answer that none are set to ‘heat’ regardless of how many radiators have the ‘heat’ value.

  • platform: template
    sensors:
    heating_summary:
    friendly_name: ‘Heating Summary’
    value_template: >-
    {% set heating_entities = states.climate | selectattr(‘attributes.hvac_mode’, ‘eq’, ‘heat’) %}
    {% if heating_entities | list | count > 0 %}
    Some climate entities are set to heat.
    {% else %}
    No climate entities are set to heat.
    {% endif %}

A climate entity’s current operating mode is reported in its state property.

- platform: template
  sensors:
    heating_summary:
      friendly_name: Heating Summary
      value_template: >-
        {% set qty = states.climate | selectattr('state', 'eq', 'heat') | list | count %}
        {{ iif(qty > 0, 'Some', 'No') }} climate entities are set to heat.

Amazing. Thank you!

1 Like