Each measurement overrides template to a device default one

Hello,

I am starting the fun with Home Assistant and have just encountered a problem with formatting temperature value displayed from my Eve Room sensor integrated to HA via HomeKit Controller. It has quite a high precision:

20.8252716064453

I would like to have it displayed rounded to 2 decimal places.

I have already tried all combinations presented here: Rounding of sensor values and setting suggested_display_precision property to 2 as described here: Sensor Entity | Home Assistant Developer Docs

The problem is that whatever I set to the state in Developer tools > States to existing part of the sensor:

temp2

this line is erased with the next update of the temperature value from the sensor. So I cannot add here anything permanently and of course any attempt of formatting the value, despite the method used, fails.

What am I doing wrong? How can I make the required template line to remain valid?

Thanks in advance!

That sensor entity is created by the Homekit Controller integration. The integration determines how the entity’s value is formatted.

In a future version of Home Assistant, there will be a way to display the entity’s value in your preferred format. Until that feature is implemented, create a Template Sensor to display the Eve sensor’s temperature the way you want.

template:
  - sensor:
      - name: "Room Temperature"
        unit_of_measurement: "°C"
        device_class: temperature 
        state: "{{ states('sensor.your_eve_room_temperature') | round(2,  default=0) }}"

Note

You can’t use Set State for this purpose. The value you set using Set State is temporary. It’s overidden by the entity’s integration which can happen when the physical device reports a new value or after a restart.

Set State is handy for testing an automation. You can force an entity’s value in order to trigger an automation (instead of waiting for the entity’s value to change naturally).

Many thanks for a prompt reply and hint! I will give it a try with Template Sensor.

Edit: works like a charm! Many thanks :slight_smile:

1 Like