Temperature view sensor HA wrong

Question about how home assistant displays the tempeture:
As you se in the picture, HA give a wired display of the tempeture line.

How is it posible to let home assitant display the tempeture like this:

I have searching on the HA website and forum, but i can find the solution.
Maybe a simple thing… Thanks for the answers.

This is my sensor code to get the code from my termpostate:

- platform: template
  sensors:
  toontemp:
    value_template: '{{ states.sensor.toon.state.split("\n")[0] }}'
  toonpowerusage:
     value_template: '{{ states.sensor.toon.state.split("\n")[1] }}'
  toongasusage:
    value_template: '{{ states.sensor.toon.state.split("\n")[2] }}'
  toonprogramm:
    value_template: '{% if states.sensor.toon.state.split("\n")[3] == "0" %}Comfort{% elif states.sensor.toon.state.split("\n")[3] == "1" %}Home{% elif states.sensor.toon.state.split("\n")[3] == "2" %}Sleep{% elif states.sensor.toon.state.split("\n")[3] == "3" %}Away{% endif %}'

First, when posting code, highlight all the code and then press the preformatted text button shown in the image below.

That way your code will post properly formatted so we can see it to help you better.

Second; have you tried using unit_of_measurement option? I have a template sensor that gives average temperature for each floor of my house and I am getting the display you are seeking. I specified the unit of measurement as degrees F as shown below:

#
#
#   Average Home Temp
#
#
     average_main_temp:
       friendly_name: 'Average Main Floor Temp'
       unit_of_measurement: "°F"
       value_template: >-
         {{ ((float(states.sensor.aeotec_multisensor_6_temperature_7_1.state) + float(states.sensor.aeotec_multisensor_6_temperature_8_1.state) + float(states.sensor.main_floor_temperature.state) + float(states.sensor.office_temperature.state)) / 4) | round(1) }}

     average_upstairs_temp:
       friendly_name: 'Average Second Floor Temp'
       unit_of_measurement: "°F"
       value_template: >-
         {{ ((float(states.sensor.upstairs_temperature.state) + float(states.sensor.upstairs_temperature_2.state) + float(states.sensor.second_floor_temperature.state)) / 3) | round(1) }}
#

Note the ‘weird’ characters in front of the “F” - this is the proper UTF-8 method of displaying the degree symbol. If you copy and paste an example with a degree symbol by itself into a YAML file, HA will not start. In your case, just replace the F with a C.

3 Likes

@rpitera, Thanks for the tip about posting, i have change the post.

And your tip about unit_of_measurement:is working!
i was thinking that it does end matter with or without. Thanks for your help, a have now a nice line grafic.

Cool, glad I could help! When you get a chance, please click on the Solved button (little check mark) so people know you were able to find your answer.

2 Likes

Hi there is solution, you have to use another line (device_class) in your humidity sensor part of configuration.yaml

  • platform: mqtt
    state_topic: ‘tele/exampleth16/SENSOR’
    name: ‘Room Humidity’
    device_class: ‘humidity’
    unit_of_measurement: ‘%’
    value_template: ‘{{ value_json.SI7021.Humidity }}’

Sets the class of the device, changing the device state and icon that is displayed on the UI (see below). It does not set the unit_of_measurement .