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

Hey @DJI I think you are trying to do something similar to what I do, which is effectively graph your heat pump power usage against the Target and Current temperature of your thermostats but only for the ones which are on?

I do this very thing with a Front End add on in Hacs - GitHub - kalkih/mini-graph-card: Minimalistic graph card for Home Assistant Lovelace UI

Looks like this on my front end

Yaml for the Mini-graph card is like this:

type: custom:mini-graph-card
entities:
  - entity: sensor.nibe_65708_43009
    name: Calculated flow temp.
  - entity: sensor.nibe_65708_40071
    name: External flow temp.
  - entity: sensor.nibe_65708_40033
    name: Room temp
  - entity: sensor.nibe_65708_47398
    name: Target temp.
  - entity: sensor.nibe_65708_40067
    name: Avg. Outside
  - entity: sensor.smart_meter_electricity_power
    name: Energy Usage
    y_axis: secondary
points_per_hour: 12
hours_to_show: 12
show:
  legend: true
  labels: true
  labels_secondary: true

Just obviously replace the sensors with your own sensors.

If you want to chat about heat pumps give me a shout. I basically take an average of my active thermostats Target and Current temperature and pass it to a heat pump so that the flow temperatures get calculated on real life requirements rather than a fixed static requirement. Seems to have increased efficiencies for us this winter. but I’ve only done it a few months ago so next winter will be a good test to see the difference.