How to create sensor that will be a average of other sensors


i have 3 different temperature sensors in 3 different rooms,
i want to create new sensor in HA that will display the average temperature of the 3 rooms.

how i can do it?

You could create a template sensor, add up all 3 temperature values and divide by 3.

You also have the option of using the Min/Max sensor and specifying its type as mean.


When using Min/Max, keep in mind that it always shows you a numeric value.
That means if ALL of your temperature sensors change their states to unknown/unavailable (low battery/no WiFi etc) it will still show the latest average.
So it’s ok for statistics, but won’t work well if you’re going to use it in automations. I had to create a custom sensor to overcome that limitation.

1 Like

Tnx for the answer can you show me an example of using this template for this solution ?

like if this is the sensors:


There’s an example of a template (adding the values of three sensors and dividing the result by three) shown in the documentation for the Min/Max sensor. From the documentation:

{{ ((float(states('sensor.kitchen_temperature')) +
     float(states('sensor.living_room_temperature')) +
     float(states('sensor.office_temperature'))) / 3) | round(2)

sorry I’m new in HA and I feel really stupid but where I am suppose to add this parameters?

I added the sensor in my configuration.yaml

   - platform: min_max
       - sensor.downstair_front_door_temperature
       - sensor.downstair_sensor_kitchen_temperature
       - sensor.hue_motion_sensor_new_temperature
       - sensor.upstair_sensor_temperature

but then where I add

{{ ((float(states('sensor.downstair_front_door_temperature')) +
     float(states('sensor.downstair_sensor_kitchen_temperature')) +
 float(states('sensor.hue_motion_sensor_new_temperature')) +
     float(states('sensor.upstair_sensor_temperature'))) / 4) | round(2)

It’s one or the other.

I have a similiar, but different questions:

How can I calculate an average temperature of the day or previous day ?
Same for energy consumptions etc.

For energy: Can I get that by deviding the daily consumption / 24 hours to get the hourly average ?


1 Like

what I found with the min_max is you need to do the max or min value

- platform: min_max
  name: kids room temperature max
  type: max
    - sensor.kids_room_temperature
    - sensor.kids_room_temperature_max

now when the room temperature is greater than the room temperature max it get updated
and that the same with the min value

I just tried the min max and I am getting an unknown for the mean value.
My three sensors all read from the development tools with correct values.

My min max is as follows:

  - platform: min_max
      - sensor.17_seaview_avenue_current_temp
      - sensor.dark_sky_current_temp
      - sensor.tasmota_outside_temp_ds18b20_temperature_2
    type: mean
    name: Ave_Outside_Temp

Not sure what to try next?

I’m also getting that same behavior on the latest HA Core and system - pretty sure my temp sensors are all okay. I’m going to look at the template sensor route instead.

Mine now work correctly now. I had a sensor with different units. They must be the same for min max to work.