Template Value not rounded

Hi guys,

I have a rain gauge which meassures the rain with a simple reed switch. I use a template to convert the “impulse” into L/m².

All works fine beside that the amount is not always rounded and looks like this:

Screenshot 2021-05-05 140058

Here is my Template where I already use “round” but it seems not working:

- platform: template
    sensors:
      regenmenge_template:
        friendly_name: "Regenmenge_L"
        unit_of_measurement: 'l/m²'
        value_template: "{{ states('sensor.regenmenge') | float * 0.30303 | float | round (2) }}"

Hope someone can help me on this :slight_smile:

You need more brackets. You are only rounding the 0.30303 number:

value_template: "{{ (states('sensor.regenmenge')|float * 0.30303)|round(2) }}"

Try some extra brackets as you are just rounding the 0.30303 and not the entity value.

value_template: "{{ (states('sensor.regenmenge') | float * 0.30303) | float | round (2) }}"

Ahh, you beat me!

Thanks guys. Seems to work :slight_smile: