Average temperature of 2 Sensors

Hey im pretty new to HA and wanted some help. I want to make an automation for my air conditioning System based on the average temperature of 2 different thermostats. I have looked on the Internet but didnt find anything that helped me for my case.
Can somebody help me here?

This will do what you want:

EDIT: Though thinking about it a bit more it does not support attributes so you have to make template sensors to extract the two temperatures from the climate devices. So you might as well just make one template sensor.

Like this, in your configuration.yaml file:

template:
  - sensor:
      - name: "Average temperature"
        unit_of_measurement: "°C"
        state: >
          {% set bedroom = state_attr('climate.bedroom', 'temperature') | float(0) %}
          {% set kitchen = state_attr('climate.kitchen', 'temperature') | float(0) %}
          {{ ((bedroom + kitchen) / 2) | round(1, default=0) }}
1 Like

Hi thanks for the help!
But now i have the problem that I want do 2 calculations in 1 template sensor.
My code looks like this:

- sensor:

      - name: "Average temperature Büro 5"

        unit_of_measurement: "°C"

        state: >

          {% set Thermostat = state_attr('climate.essentials_smart_home_heizkorperthermostat_premium', 'current_temperature') | float(0) %}

          {% set Klima = state_attr('climate.te', 'current_temperature') | float(0) %}

          {{ set Heizung = ( Thermostat / 10 ) | round(1,default(0)) }}

          {{ (( Heizung + Klima) / 2) | round(1,default(0)) }}

Can anybody help me find the problem here?
Thx