Averaging sensor values

I am trying to get an average value for a set of temperature sensors, and would like to avoid 'unavailable; or 'unknown; kind of values if any of my sensors goes out;

{{
[states('sensor.den_temperature'),
states('sensor.office_temperature')]
| reject ('in',['unavailable','unknown','none'])

|average(0)

}}

Above code outputs value of zero. This is fixed by suffixing each of the inputs with | float.
But, then no longer works if any of the sensors becomes unavailable.

What am I doing wrong?

try this

  - platform: min_max
    name: Den Office Average
    type: mean
    entity_ids:
      - sensor.den_temperature
      - sensor.office_temperature
1 Like

Stephan’s suggestion is a good one and one I use too, but to fix your template (as an educational opportunity), put map('float') after the reject.

1 Like

Thanks both.
I learned something new today@ 3am :slight_smile:

1 Like