Temperature Measurement with 2 decimals on New ST App

I have connected a sensor on ST and I want to display 2 decimals instead of 1 that is now.

for example:
10:38 -> 0,45
10:33 -> 0,41

Any suggestions?
This is the part of the code

def parse(String message) {

    Map msg = stringToMap(message)
    Float temp = msg.temperature.toFloat()
    def event = [
        name  : "temperature",
        value : temp.round(2),
        unit  : tempScale,

    TRACE("event: (${event})")

P.S: on old ST app the temperature displayed correctly with 2 decimals.

Until recently the old app and the new app was parsing only values without decimals.

The method to get the two decimals is a bit different, as it was parsed as text and not as a value first and split the two decimals from the text.

The new app probably able to display only 1 decimal as the UX plugin was designed for that purpose.

Otherwise why do you need two decimals? Do you have really high precision temperature sensors which has that level of accuracy? Most of the available sensors in the market has usually +/- 0.5 Celsius accuracy, but they capable to provide 2 decimals.

random number generation

Look at this topic, search for the phrase description if you do not want the read the whole conversation.

Thanks your your reply.
It’s not actually a temperature sensor.

I have connected a Geiger Counter to ST and since there is no related capability I’m using the temperature capability to pass these values to DH

The counter is reporting float numbers and what’s why I need 2 decimal precision

Ok, then look here, create your custom capability and define it as state, not slider.

Then you can parse any decimal value and you can call it anything you want, not just temperature, and it will work with the new app.

1 Like