Help with template calc

Hi all,
I have a sensor that reads data via an API. In order to interpret that and display it in Lovelace I am using a template.

Next power outage is in {{ [( as_timestamp(states.sensor.next_loadshedding_time.state) | int - as_timestamp(now()) | int ) / 60,-1] | max }} min

And it does work. I am getting “Next power outage is in 63.28333333333333 min”
What can I add or change in my template to show that the next outage is in 63,28 min or even just 63 would be great.
I tried “round” but don’t really know where or what to put in

Please help :flushed: :pleading_face:

round(2)

From the documentation:

  • Filter round(precision, method, default) will convert the input to a number and round it to precision decimals. Round has four modes and the default mode (with no mode specified) will round-to-even. If the input value can’t be converted to a float, returns the default value, or if omitted raises an error.
    • round(precision, "floor", default) will always round down to precision decimals
    • round(precision, "ceil", default) will always round up to precision decimals
    • round(1, "half", default) will always round to the nearest .5 value. precision should be 1 for this mode

Put it after the max filter.

| max | round(2) }} min

Use round(0) to eliminate any fraction of a minute (however if the value is 0.4 then it will be reported as 0).

1 Like