Rounding template value

Hello,

The battery runtime of my ups is diplayed in “seconds” i made a sensor that reads the value and divide it with 60 to get “minutes”
I just can’t manage to end up with 2 decimal places.
Always it end up like “76.86666666666666”

- platform: template
  sensors:
    ups_runtime:
      friendly_name: "UPS Runtime in minutes"
      unit_of_measurement: "minutes"
      value_template: "{{ states('sensor.ups_battery_runtime') | float / 60 | round(2) }}"

Try this:


value_template: "{{ (states('sensor.ups_battery_runtime') | float / 60) | round(2) }}"
1 Like

Hi many thanks, that does the trick. :grinning:
I tried with “| float / 60)” but i forgot “(” for states