frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Duration field in days is showing in hours

Open jimmyd-be opened this issue 1 year ago • 9 comments

Checklist

  • [X] I have updated to the latest available Home Assistant version.
  • [X] I have cleared the cache of my browser.
  • [X] I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

When there is a field with device class duration and native unit of measurement in days the UI is showing it in hours. This is not really readable for users. For example the UI shows 3288:00:00 and this represents 137 days.

Describe the behavior you expected

I think it is better to just show the days here. So that 137 days are shown instead of 3288:00:00.

Steps to reproduce the issue

  1. Show a duration day field in the UI
  2. This will show the hours instead of days

...

What version of Home Assistant Core has the issue?

2023.10.1

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

No response

Which operating system are you using to run this browser?

No response

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

jimmyd-be avatar Oct 08 '23 11:10 jimmyd-be

+1 on this. The Entity Card and History graph Card shows the "raw" value but the rest of the card do convert the value to HH:MM:SS without ability to change unit of measurement in the entity settings.

Skärmavbild 2023-12-08 kl  10 37 16 Skärmavbild 2023-12-08 kl  10 37 37

moorgrove avatar Dec 08 '23 09:12 moorgrove

+1 on this. I have a 14 days intervall entity that is showing days in the format HH:MM:SS. image

Core 2023.12.1 Supervisor 2023.11.6 Operating System 11.2 Frontend 20231208.2

OscarHaraldsson avatar Dec 13 '23 09:12 OscarHaraldsson

At worst, this should be also configurable by the underutilized format property. So we can decide if we want to show a specific duration in a different scale, instead of having the entities card forcing that into hours.

As a workaround, I'm using type: custom:template-entity-row, as it gets the raw days value.

Also, this is almost duplicated by #18561 - it seems the issue is the same, but reporting a different unit and other cards. An old bug, wrongly closed as stale, was also reported at #15103.

igorsantos07 avatar Jan 13 '24 23:01 igorsantos07

I don't have a perfect solution for this, but I did merge a change such that if you set a display_precision for a duration sensor, we will not attempt hh:mm:ss formatting, it will only display the exact original state formatted to the requested precision.

Might not be a perfect solution but I hope that's a satisfying compromise.

karwosts avatar Jan 15 '24 14:01 karwosts

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 14 '24 18:04 github-actions[bot]

Not fixed at all.

jimmyd-be avatar Apr 14 '24 18:04 jimmyd-be

Yes, I can confirm that with HA 2024.4.1:

image

vs

image

freakyjoe8 avatar Apr 25 '24 14:04 freakyjoe8

@karwosts while that seems to do the trick, at least in my scenario (days), I'd say this is not intuitive for most users. If you have a day sensor, you expect it to ALWAYS show in days. It makes no sense at all having to configure precision to only THEN show it in days.

Not to mention the precision field is actually related to decimal spots, not to units/subunits, so it's quite an unexpected place to have that "fixed". I had to dig HA a bit to find the setting mentioned in your PR.

igorsantos07 avatar Apr 26 '24 18:04 igorsantos07

I don't disagree with you, I know it's not perfect, though it's just the simplest compromise I could come up with.

Another member added a while back this hh:mm:ss display format for all duration sensor, and I don't necessarily want to just go in and rip out their work, as this is somewhat subjective, and some people may prefer that format for some cases. E.g. if you had a sensor with a unit of seconds and the value was 10,000 seconds, many people would probably prefer the human readable format, versus saying that it must always display exactly in seconds.

How to decide when to display one format versus another is not something I have a definitive answer for.

karwosts avatar Apr 26 '24 19:04 karwosts

Sorry, I never meant to spit on your work - I totally get you, and given the way issues are overlooked around here, I'm actually surprised anyone could do something about the topic. Congratulations! haha What I meant is: to whomever arrives here in the future, that PR solely does not fix the whole issue, it's mostly a mild patch, in a weird manner (given it depends on a sensor setting mostly related to decimal places).

That all said, to expand on your questioning of what could be a definitive solution for the issue: do you see any impediment on adding further functionality on format? E.g., besides date/time/datetime, also allowing us to feed it a specific unit such as minutes/seconds/days, etc.

igorsantos07 avatar May 02 '24 06:05 igorsantos07

I'm not so sure about format, as I don't think it fully solves this issue, given that like the more-info will still use the default display. Maybe if someone contributed a change to use format it might be accepted though 🤷‍♂️ . I think there's still some inconsistencies overall around format, given that it seems some cards support it and some do not.

karwosts avatar May 02 '24 13:05 karwosts

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 31 '24 15:07 github-actions[bot]

stale-proof comment

igorsantos07 avatar Aug 02 '24 00:08 igorsantos07

I got a custom sensor with unit of measurement in days (at the moment 47 days, according to the state shown via developer settings). But when used in a tile card its showing me the raw number 1128:00:00 when the entity settings are set to display precision "default (47)". When I change the settings to "47", it shows 47 days as in the developer settings, which is correct.

But it shouldnt make a difference in the first place. Possible bug?

tobse91 avatar Aug 03 '24 09:08 tobse91

But it shouldnt make a difference in the first place. Possible bug?

See my comment above:

I did merge a change such that if you set a display_precision for a duration sensor, we will not attempt hh:mm:ss formatting, it will only display the exact original state formatted to the requested precision.

Might not be a perfect solution but I hope that's a satisfying compromise.

karwosts avatar Aug 03 '24 15:08 karwosts

Maybe it would be better to change the format based on the actual value? Say a sensor reports 0.012 seconds, show 12 ms. But if it's reporting more than 1 second but less than say an hour, format it to minutes, etc. This way you shouldn't get those ridiculously large numbers.

Ghoelian avatar Aug 12 '24 09:08 Ghoelian