New Helper Type: input_duration

We need a new helper type to manage units of time expressed and displayed as durations, rather than time of day. In the past, input_datetime (with has_date=no, has_time=yes) suited this purpose when it used to display time in 24H terms, but now that it displays time in 12H terms, it is an irrational input field for specifying durations (for example, when using input_datetime to specify 10 minutes duration, it must be input as “12:10 AM”, reflecting it’s true intended use for handling time of day values).

I propose a new passive helper (possibly called “input_duration” and existing only to provide a UI input field and state value to be read by a rule) which accepts a duration value (via the UI) as in this example:

The value returned by a call to “states('input_duration.xxxxx')” (using the above example as input) should take the form “00:10:00”, same as does input_datetime with has_date=no.

I like it.

+1

Would also be interested in something like this.

Is there or could there be an easy way to access/edit attributes from the UI/dashboard?
Then this could be done using a timer entity. {{state_attr('timer.x', 'duration')}} already returns “%H:%M:%S”

That’s not a bad idea. I just ended up going with number and doing the fraction math myself, but I’d still be interested in formal support for this.

This HACS integration might interest you:

I like the idea of a input_duration component.
How should the UI look like?

Should it be like the input_datetime time
Where you have sperate input fields for hours minutes and seconds or should there be one input field where you could type in seconds or maybe even milliseconds.

After reading some more i think the UI should consist of 5 fields:

  1. days
    2 hours
  2. minutes
  3. seconds
  4. milliseconds

There has been no change to this. This is just a setting in your profile.

Time only input_datetime in 24H format:

Screenshot 2024-07-31 at 17-33-59 Overview – Home Assistant