COP calculation out of sensors

Hi all,

I’m struggling with the COP calculation of my heatpump. In sensors.yaml i’ve created this code:

#Realtime COP berekening
- platform: template
  sensors:
    realtime_cop:
     friendly_name: 'Realtime COP'
     value_template: >
       {% set deltat = states('sensor.deltat') | float %}
       {% set pump_raw = states('sensor.shelly_pro3em_total_active_power') | float %}
       {% if pump_raw > 0} 
       {{ ((deltat * 4.2) * (24 / 60) / pump_raw) | round(1, default=0) }}
       {% else %} -1
       {% endif %}

But I get a syntax error. What I would like to do is to create the COP based on the data of deltat sensor and my current power consumption.

The formula is:

(DeltaT * 4.2) * (24 / 60) / actual power consumption

Any ideas?

{% if pump_raw > 0}

“%”

{% if pump_raw > 0 %}
1 Like

Thanks for helping! I don’t have any errors in the yaml anymore.

But I see the result of the formula is always 0.0. What am I missing?