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.
The problem is that whatever I set to the state in Developer tools > States to existing part of the sensor:
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?
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.
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).