How to format a card to show hours instead of seconds?

I have a Miio entity (a vacuum) which shows various properties:

As you can see, values are shown in seconds.
It’s fine for the integration page, but in the dashboard I would like to have hours.

Is it possible without having to define an extra template sensor? Formatting “on the fly” depending on the dashboard seems like a reasonable use case…


1 Like

As far as I know, no.
But I think it would be a good change in the integration.
Who would want it in seconds?
Minutes is perhaps more useful but still, hours is probably the most useful here.

I think the integration is fine and changing it would even affect long term storage of data, it’s the dashboard that should allow reformatting numbers.

1 Like

I’ve run into this, too. Just recently in 2022.5 something changed and now some of my dashboard displays which were in decimal hours are in HH:MM:SS format. That’s OK, but I don’t need the seconds to display. It only makes the screen look cluttered.

In hopes of avoiding the flood of responses I know would come, let me be clear: I know I can create a template in whatever format I want. I’ve got dozens of templates already. I don’t think it’s a good practice to create templates (data) simply to display a value. The display should be separate from the data.

This isn’t the first time this has come up. A quick search came up with this question, and a few Feature Requests. I suggest up-voting any you agree with:

There are no doubt more discussions on this; I just did a very quick search.

I agree. Creating templates to format a value is like cracking walnuts with a sledgehammer.

There was an issue raised when the Xiaomi vacuum changed from hours to seconds. The devs indicated that as a policy they no longer change the units reported by the device and it would not be changed. So we are probably going to see more of this sort of thing.

1 Like

I think it’s reasonable.

I didn’t find them, I guess my search used the wrong terms.


The groundwork is in place for this to be handled by the UI in the future. In 2022.4 (maybe 5), a new sensor device class duration was added. As long as a sensor has the following things set:

  • Has a value of hours, minutes, or seconds
  • Corresponding unit_of_measurement, h, m, or s
  • device_class: duration

The UI will display the value as d HH:MM:SS. Where d is days, HH is hours, MM is minutes and SS is seconds.

In the future, I could see a setting in the UI being added for the display on a duration sensor.

To add this functionality to the vacuum sensors, just manually customize the entity with

device_class: duration

Also, you should open an issue against the integration that’s creating those entities, as they should be setting the duration device class.


Thanks. I’ll open the issue for the Xiaomi/Milo vacuum as they do not have the device class, e.g.

Though I would still need my template sensors to convert the values to hours for the bar cards I use as row elements:


1 Like