Combining sensor outputs: difference

Hello! The ability to combine the outputs of sensors so easily is great. I think an option is missing though. I would like to be able to create a helper that returns the difference between two sensors. For instance, I have two temperature sensors in my room, one placed high up and one placed down low. By combining these and getting the average I have a better idea of the felt temperature of the room. But if I could see the difference between the temperatures I could use that to trigger something like turning on a fan to circulate the air to even out the temperatures.

I hope that makes sense and it’s a useful suggestion. Thanks!

Please see this post regarding subtraction (difference): Helper: Subtract/Add/devide/multiply two sensor values - #39 by petro

You will have to create a yaml sensor.

template:
  - sensor:
      - name: Temperature Difference
        device_class: temperature
        state_class: measurement
        unit_of_measurement: "°C" # or F
        state: "{{ states('sensor.up_high')|float(0) - states('sensor.down_low')|float(0) }}"
        availability: "{{ has_value('sensor.up_high') and has_value('sensor.down_low') }}"