Set my own sensor status

Hi guys
at the moment my Home Assistant runs mostly with sensors from the forum. Copy and Past is very simple.

But now I want to create a sensor with its own status and learn how it works. Unfortunately my knowledge is not enough yet.

One of my sensors shows a decimal number based on the temperature difference. For me this is also OK.

template:
  - sensor:
      - name: "Temperature Difference"
        unit_of_measurement: "°C"
        state: >-
         {{ ( states('sensor.govee_1_temperature')|float(0) - states('sensor.govee_2_temperature')|float(0) )|round(2) }}

But now I want to build a sensor for the family that shows “cold” for a negative number and “hot” for a positive number.

Should it not be too difficult, best still in blue and red :wink:

Thank you guys

if 1 is larger than 2, hot, else cold

        state: >-
         {{ 'hot' if ( states('sensor.govee_1_temperature')|float(0) > states('sensor.govee_2_temperature')|float(0) )  else 'cold' }}
1 Like

Thank you for your answer, briefly I thought I understood. But I think I still have a lot to learn. It does not work yet.

I have guessed it is a binary sensor. Unfortunately, it is not displayed in the entities. I am doing something wrong.

template:
  - sensor:
      - name: "Temperature Difference"
        unit_of_measurement: "°C"
        state: >-
         {{ ( states('sensor.govee_1_temperature')|float(0) - states('sensor.govee_2_temperature')|float(0) )|round(2) }}

  - binary_sensor:       
      - name: "Temperature Difference Easy"
        state: >-
         {{ 'hot' if ( states('sensor.govee_1_temperature')|float(0) > states('sensor.govee_2_temperature')|float(0) )  else 'cold' }}   

Binary sensor can only be on/off.
You wanted hit or cold, so it has to be a sensor.

oh man i’m getting embarrassed.
it just doesn’t work.
I only see the first sensor

sdgsdg

template:
  - sensor:
      - name: "Temperature Difference"
        unit_of_measurement: "°C"
        state: >-
         {{ ( states('sensor.govee_1_temperature')|float(0) - states('sensor.govee_2_temperature')|float(0) )|round(2) }}

  - sensor:       
      - name: "Temperature Difference Easy"
        state: >-
         {{ 'hot' if ( states('sensor.govee_1_temperature')|float(0) > states('sensor.govee_2_temperature')|float(0) )  else 'cold' }}

EDIT: in the developer tools i found the template page. So I could see the syntax error.

Thanks again.

1 Like