Can I summarise multiple climate entities?

I’m struggling to work out how my heat pump & underfloor heating is working and I’m busy gathering data to help. I’d like to know how many UFH zones, if any, are on and to be able to graph this against the power drawn by the heat pump. My first problem is in creating an entitiy that summarises the states of all 12 UFH zones. Is this possible?
The entities are all like climate.[zone]_neo, and they have all come from HomeKit Controller - Home Assistant linked to a Heatmiser Neohub. They all have these attributes

hvac_modes:
  - heat_cool
min_temp: 5
max_temp: 35
current_temperature: 19.5
temperature: 19
hvac_action: idle
friendly_name: Bathroom 1st floor Neo
supported_features: 1

I had in mind an entity that has a count of the number of climate entities which are in the state: “heating” (and could ideally also have the average temperature). I had assumed I could create a helper to do this, but I can’t work out how.

This should give you this part…hopefully!

{% set ns = namespace(count = 0) %}
{% for climate in states.climate if 'heating' in climate.attributes.hvac_action %}
{% set ns.count = ns.count+1 %}
{% endfor %}  {{ns.count}}

Not so sure on this though.

Thanks for this. I’m really an early learner - where do I put this code? Will this give me a history that I can add to a time-series graph?

Ah OK, sorry.

You will need to create a template sensor for this. To do this you will need access to your configuration.yaml file and will need to add:

template:
  - sensor:
    - name: number of climate in heating # or any other name you want #
      state: >
        {% set ns = namespace(count = 0) %}
        {% for climate in states.climate if 'heating' in climate.attributes.hvac_action %}
        {% set ns.count = ns.count+1 %}
        {% endfor %}  {{ns.count}}

If you haven’t done so already you can add the ‘file editor’ addon via settings / add-ons to allow easy access and editing of your configuration.yaml.

PS: after adding to or editing the configuration.yaml and once checking your configuration is valid via developer tools / yaml, you may need to restart home assistant for the changes to take place.

Thank you so much - it worked a treat! I wish I understood how to do that…
Is it possible to produce an average temperature of all the zones and just the heatings zones in the same loop?

FYI

If you ever need a means of easily controlling multiple climate entities, daenny developed a custom integration allowing you to create a Climate Group.


BTW, the Template Sensor can be reduced to this:

template:
  - sensor:
      - name: Heating Quantity
        state: "{{ states.climate | selectattr('attributes.hvac_action', 'eq', 'heating') | list | count }}"
1 Like

Thanks. That worked well until I tried to graph the result against other numeric entities. I added an INT pipe but didn’t seem to make it a graphable number.

  - sensor:
    - name: Neo zones heating
      state: "{{ states.climate | selectattr('attributes.hvac_action', 'eq', 'heating') | list | count | int }}"

If you want a line graph instead of a bar then you need to add a unit_of_measurement.

template:
  - sensor:
      - name: Heating Quantity
        state: "{{ states.climate | selectattr('attributes.hvac_action', 'eq', 'heating') | list | count }}"
        unit_of_measurement: 'zones'
1 Like