Average sensor without zero value

Hey guys,

I’m measuring the COP of the heat pump with the following template sensor:

      - name: "COP with cooling"
        unit_of_measurement: "COP"
        state_class: measurement
        state: >-
          {% if
            state_attr('sensor.althermasensors','Operation Mode') in ('Heating', 'Cooling')
            and state_attr('sensor.althermasensors','Freeze Protection') == 'OFF'
            and state_attr('sensor.althermasensors','INV primary current (A)')  | float != 0
          %} 
          {{ 
            (
              (
                state_attr('sensor.althermasensors','Flow sensor (l/min)') | float
                * 0.06
                * 1.16
                *
                  (
                    state_attr('sensor.althermasensors','Leaving water temp. before BUH (R1T)') | float
                    - state_attr('sensor.althermasensors','Inlet water temp.(R4T)') | float
                  )
              )
              /
              (
                state_attr('sensor.althermasensors','INV primary current (A)') | float
                * 230 | float
                / 1000
              )
            )
            | round(2)
            | abs
          }}
          {% else %} 0 {% endif %}

This works fine, but I want to know the average daily COP so I’ve created this:

- platform: statistics
  name: "Average COP"
  entity_id: sensor.cop_with_cooling
  state_characteristic: average_linear
  max_age:
    hours: 24

Only issue: This is getting me the average over the last 24 hours, including all the zero values.

How can I make a sensor that is giving me only the average daily value without any zero values?