Change state temperature 99.999 text to 99.9°C format numeric

Hi, I made a zigbee module with 2 * ds18b20 temperature sensors and a relais to control my Jacuzzi.

I get the temp. through zigbee2mqtt in home assistant as a text value with 3 decimal numbers. (99.999)
I like to change the text value to a numeric value with 1 decimal (99.9) but I don’t know where to start to do that.

This is what I get as text value:

  1. Click the small information icon next to “Jacuzzi temp/vermarming L2 I2”.

  2. Click the gear icon in the upper right corner.

  3. Change the “Display Precision” option to display just one decimal place.

Internally, Home Assistant will continue to record the sensor’s values to whatever precision is received (three decimal places). However it will display the value to whatever you set “Display Precision”.

Is that really possible when the entity in the screenshot belongs to domain text rather than sensor? Might need to feed this entity into a template entity sensor…?

I don’t have any text entities so I don’t know for sure but, giving it further thought, I agree with you that “Display Precision” is probably not available for text entities (because their value isn’t limited to being a number).

In that case, yes, they’ll need to make a Template Sensor (and decide if they want Recoder to maintain a history of both entities or exclude one of them).

I just had a look and there is no display precision on text .
How can ! change the text to a number or a sensor?

In that case, you will need to create a Template Sensor helper that reports the text entity’s value but with just one decimal place.

In other words, you have to create a separate entity to report the value the way you want to see it displayed.

Go to Settings → Devices & Services → Helpers → Create Helper → Template → Template a sensor

Give it a name and put this in the State Template field.

{{ states('text.0x00124b002734e016_l2') | float(0) | round(1) }}

It worked perfect

test

1 Like