[SOLVED] New template for Heatpump COP calculation : How to do it?

I’ve got an Ariston Heatpump integrated via eBusd into HA.
I’m gathering all the metrics needed to calculate the COP of the HP, this in all the possible running configurations.
I already have a formula that calculate the instantaneous COP, based on LWT, EWT and flowmeter readings.

          {% if ((states('sensor.ebusd_heatpump_ebusd_heatpump_compressor_info_flow_meter') | float (default=0)) > 15
            and (states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_info_heatpump_mode') | string ) != 'Stand_by') %}
                   {{ ([0,(((((states('sensor.ebusd_heatpump_ebusd_heatpump_coolat_data_lwt_temp') | float (default=0)) - 0.2 - (states('sensor.ebusd_heatpump_ebusd_heatpump_coolat_data_ewt_temp') | float (default=0)) | abs) * (states('sensor.ebusd_heatpump_ebusd_heatpump_compressor_info_flow_meter') | float (default=1)) * 60 * 1.16) / (states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_power_consumption') | float (default=1))) |abs |round(2)),8]|sort)[1] }}

The calculations take into account the conversion from DeltaT in °C to KW/h and the l/min to M3/h ratio conversion.
I’ll beautify my horrendous code following a hint found here on the forum during my search

 {% set vl = states('sensor.LWT') | float %}
  {% set rl = states('sensor.EWT') | float %}
  {% set vol = states('sensor.Flowmeter') | float * 60 %}
  {% set powercons = states('sensor.powercons') | float %}
  {% if powercons != 0 %}
    {{ ((vl - rl) | abs) * vol * 1.16) / powercons }}
  {% else %}
   ????
  {% endif %}

I need help to figure out how to add a little more complexity to the template:

  • the returned value should be unavailable if the flowmeter is zero: I want to calculate average COP over longer time periods and when the HP is not running then these value should not alter average calculations
  • when the heatpump is doing defrost operations
    states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_info_heatpump_mode') | string ) = 'Defrost'
    then the calculated COP should be negative, as the enegy used is not going into the house but wasted in deicing the battery
  • the COP value should be limited into a range let’s say 0-8 because in some corner cases I’ve experimented in the last months the readings may lead to exaggerated values

Can you give me an hint on the syntax to obtain a credible COP calcs?

TY

If you want to use the availability feature, you have to use YAML config at the moment. Something like this:

template:
  - sensor:
    - name: "COP"
      state: >
        {% set vl = states('sensor.lwt')|float(0) %}
        {% set rl = states('sensor.ewt')|float(0) %}
        {% set vol = states('sensor.flowmeter')|float(0) * 60 %}
        {% set powercons = states('sensor.powercons')|float(0) %}
        {% set neg = -1 if is_state('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_info_heatpump_mode', 'Defrost') else 1 %}
        {{ neg * ((0, (((vl - rl) | abs) * vol * 1.16) / powercons, 8)|sort)[1] }}
      availability: >
        {{ states('sensor.flowmeter')|float(0) > 0 and
           states('sensor.powercons')|float(0) > 0 }}
1 Like

many thanks @Troon !!!
I’ve made some slight adaptations to exclude some mode (eg when the HP is in stand-by mode) and voila!

Now I’ll test it till the first defrosts (this night surely) and see what it will spat out…

Many thanks again, great community here!

Hi @Troon many thanks for your hint, I’ve made it, this is the final product:

        state: >
          {% set lwt = states('sensor.ebusd_heatpump_ebusd_heatpump_coolat_data_lwt_temp')|float(0) %}
          {% set ewt = states('sensor.ebusd_heatpump_ebusd_heatpump_coolat_data_ewt_temp')|float(0) %}
          {% set vol = states('sensor.ebusd_heatpump_ebusd_heatpump_compressor_info_flow_meter')|float(0) * 60 %}
          {% set powercons = states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_power_consumption')|float(0) %}
          {% set neg = -1 if is_state('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode', 'Defrost') else 1 %}
          {{ neg * ((0, ((((lwt - ewt - 0.2) | abs) * vol * 1.16) / powercons)|round(2), 8)|sort)[1] }}
        availability: >
          {{ states('sensor.ebusd_heatpump_ebusd_heatpump_compressor_info_flow_meter')|float(0) > 0 and
             states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_power_consumption')|float(0) > 0 and
             ( states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Heating' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Defrost' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Cooling' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Heating_boost' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Cooling_boost' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Heating_rating' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Cooling_rating' ) }}

It needs a little thinkering because I’ve noticed that the HP mode sensor switch to defrost a little late than the actual switching of the HP mode but the number are far more realistic now.

Many thanks again
EDIT: fixed powercons sensor and HP mode sensor

Hi, I’ve got an Ariston Heatpump two and wanted to use your example to calculate the COP. I face the problem that the ebusd_heatpump_heatpump_info_heatpump_mode does not give valid values. The ariston.csv contains some none compatible info. What CSV file do you use for your Ariston HP?

Hi,
I’m using the file ariston.csv from my repo:

but there was an error in the previous post, this is the correct yaml I’m now using:


          {% set lwt = states('sensor.ebusd_heatpump_ebusd_heatpump_coolat_data_lwt_temp')|float(0) %}
          {% set ewt = states('sensor.ebusd_heatpump_ebusd_heatpump_coolat_data_ewt_temp')|float(0) %}
          {% set vol = states('sensor.ebusd_heatpump_ebusd_heatpump_compressor_info_flow_meter')|float(0) * 60 %}
          {% set powercons = states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_power_consumption')|float(0) %}
          {% set neg = -1 if is_state('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode', 'Defrost') else 1 %}
          {{ neg * ((0, ((((lwt - ewt - 0.2) | abs) * vol * 1.16) / powercons)|round(2), 8)|sort)[1] }}
        availability: >
          {{ states('sensor.ebusd_heatpump_ebusd_heatpump_compressor_info_flow_meter')|float(0) > 0 and
             states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_power_consumption')|float(0) > 0 and
             ( states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Heating' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Defrost' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Cooling' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Heating_boost' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Cooling_boost' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Heating_rating' or
               states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode')|string == 'Cooling_rating' ) }}

Tip to save all that repetition:

        availability: >
          {{ states('sensor.ebusd_heatpump_ebusd_heatpump_compressor_info_flow_meter')|float(0) > 0 and
             states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_power_consumption')|float(0) > 0 and
             (states('sensor.ebusd_heatpump_ebusd_heatpump_heatpump_mode') in
              ['Heating', 'Defrost', 'Cooling', 'Heating_boost', 'Cooling_boost', 'Heating_rating', 'Cooling_rating']) }}
2 Likes

Thanks for the reply. I use the same CSV and it is great for most part. The only thing is that this heatpump mode only shows “Cooling_rating” and no other states. How can this happen?

Let’s not continue here as the issue is solved.
We can move the discussion on the integration thread.