Duration Capability & Template

Hopefully I'm not missing something that already exists as this seems simple and necessary. I'd like a template that is used to display durations of time that a driver may be keeping track of.

The duration would be stored as an integer number of seconds. Since this is for user-interface I don't see a need for sub 1 second resolution here.

The template would display the two (or three?) most significant units.


  1. Duration is greater than 1 minute: "Minutes: MM:SS"
  2. Duration > 1 hour: "Hours: HH:MM"
  3. Duration > 1 day: "Days: DD:MM"

Or something like that anyway.

Forgive me for being dense this aft'noon, but I'm not getting a clear picture. Sounds like you want a ¿tile? on a dashboard that displays multiple running times? Not impossible assuming there's an attribute or automation to draw it from I guess, but that's my other question - what do you see are being the source of this information?

You're not being dense, just trying to understand the request :smiley: Some devices have a running time that the device has been on for. One example is the Wemo Insight has the number of seconds that a given device has been drawing current for that is above a threshold. This is a "duration" in time. The field would be updated whenever the device it self updates its state. The dashboard would simply reflect this.

Might be nice to have the running counter for other purposes, but just reflecting duration that is updated from from the device itself would be good too.

I can see lots of reasons a device might want to count how long something has been active, or time that it has been inactive. These kinds of durations would be useful in rule engine for kicking off some sort of trigger based on some duration that a device is timing.

In another thread, for which you were kind enough to point out my folly today, I posted about "Last Update/Activity" of a device. Having my driver update a field with duration since last activity (it would need to have a periodic call to update this variable) would be more helpful that displaying Last Activity. I am more interested in knowing that the device hasn't been heard from in 10 minutes than that it was last heard from at 1:13:23 pm. Since I am interested in duration in this case, I have to do math (very difficult math LOL) to determine the duration rather than having the value already in the format I need it in.

Sounds like this may be available for display by an attribute tile:

While it would be nice to have the tile formatted in a duration format (e.g. HH:MM:SS)... An integer display of seconds or minutes would suffice. Do you have a particular Capability in mind that has an Integer Attribute that I could set? I can't seem to find a Capability that has an appropriate attribute for duration.

I could convert to a string and use the "Variable" capability, but then not sure if Rule Engine could actually read it and interpret it as an integer.

Generally I’ve seen it stored as a number of seconds since if the driver has a repeating update, or a function that will rerturn the number of seconds. Both would be available to your favorite rule engine which should be able to reformat it as required.