Card in minutes and seconds

I’ve got a UPS sensor that is coming back in seconds and I’d like to put it in a card in minutes and seconds.

I’ve been reading posts going back some way about making a template for it in configuration.yaml and I was thinking… “Surely there’s an easier way of doing this now?”

I’ll tell you my concerns. Sensors and cards come and go as devices are added and removed. As builds grow and get more complex, extra bits of code and configuration can get forgotten about and cause problems further down the line. So I’d rather be able to solve this in a card rather than having to create a template.

Grateful for thoughts please.

Use a markdown card.

{{ states('sensor.ups')/60|int(0) }}:{{ states('sensor.ups')%60 }}

Solved it… Using a markdown card. Wally also kindly provided the code to insert the icon.

**UPS Runtime <ha-icon icon="mdi:lan-pending"></ha-icon>**
## {{ states('sensor.pro1600_battery_runtime') | int(0)
  | timestamp_custom('%-Hh %-Mmin %-Ssec', false)
  | regex_replace('(^0h| 0min| 0sec$)', '')
  | regex_replace('(^ )', '') }}

karwosts also later said, “If it is a duration sensor, if you change the unit_of_measurement in the entity settings to minutes, it will display as “mm ss” in most frontend cards.” which also worked.

Thanks. Sorry, didn’t see you typing.

<ha-icon icon="mdi:lan-pending"></ha-icon>

Brilliant! Thank you very much!

If it is a duration sensor, if you change the unit_of_measurement in the entity settings to minutes, it will display as “mm ss” in most frontend cards.

That’s great. It works in my case. It throws the history graph off a bit! I saw the number hit the deck and my heart nearly skipped a beat!