frontend
frontend copied to clipboard
Duration field in days is showing in hours
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
- Show a duration day field in the UI
- 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
+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.
+1 on this. I have a 14 days intervall entity that is showing days in the format HH:MM:SS.
Core 2023.12.1 Supervisor 2023.11.6 Operating System 11.2 Frontend 20231208.2
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.
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.
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.
Not fixed at all.
Yes, I can confirm that with HA 2024.4.1:
vs
@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.
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.
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.
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.
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.
stale-proof comment
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?
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.
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.