Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve duration formatting #23025

Merged
merged 2 commits into from
Nov 27, 2024
Merged

Improve duration formatting #23025

merged 2 commits into from
Nov 27, 2024

Conversation

piitaya
Copy link
Member

@piitaya piitaya commented Nov 27, 2024

Proposed change

Entity card example

CleanShot 2024-11-27 at 14 50 37

Partial fix for #21346 (graph tooltip is not part of this PR as it requires more work)
Partial fix for #20533 (time default formatting is not part of this PR)

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@bramkragten bramkragten merged commit 164944c into dev Nov 27, 2024
16 checks passed
@bramkragten bramkragten deleted the duration_improvements branch November 27, 2024 14:00
@ntompson
Copy link

Handling of durations seems to have gone backwards since this update. For example:

Screenshot 2024-12-15 at 8 41 34 PM Screenshot 2024-12-15 at 8 41 47 PM Screenshot 2024-12-15 at 8 41 55 PM

I don't have pre-upgrade screenshots, but I'm pretty sure these were formatted more reasonably (hours, minutes and so on).

@piitaya
Copy link
Member Author

piitaya commented Dec 15, 2024

The old format was hh:mm:ss and didn't use the unit of measurement.

With the new update, the unit of measurement is taken into account. You can choose the unit using the entity settings. What integration are you using? May be it needs a update to provide the right unit by default.

CleanShot 2024-12-15 at 11 13 37@2x

CleanShot 2024-12-15 at 11 13 42@2x

@ntompson
Copy link

Ok great! I didn’t realise that would work. These examples come from ESPHome projects I’ve built myself; they are configured as durations in seconds in ESPHome config. But your method works nicely, so thanks

@craibo
Copy link

craibo commented Dec 19, 2024

Good day

Can we please get this reverted.

The unit of measure is what the base value is provided in.

For activity sensors where the duration can range between seconds to minutes to hours to days for the same entity value, you cannot hard set the unit of measure.

The dynamic formatting which handled these scenarios was very beneficial in these cases.

A different approach is required here please.

Thank you

Bug ref #23338

@craibo
Copy link

craibo commented Dec 20, 2024

Good day @piitaya, @bramkragten

After further discussion on #23338 would it be possible to by default use the previous functionality that automatically formatted the value in a human readable way.
Then the users can decide to use your unit of measure enhancement to override this and force the unit of measure to be used for display?

Also the unit of measure selection field is not showing for me to select on the latest version.

Thank you

@jouster1974
Copy link

I'm seeing some issues with the new formatting in an integration that previously worked fine with activity lengths being shown in hours, minutes and seconds..whereas now it just shows in seconds.

Please see my further info from my previously logged bug below

Since 2024.12, the time duration seems to have changed to only seconds...and it no longer appears to be possible to change this after a core change, so its no longer possible to show duration in hours, minutes and seconds

395815419-603270d8-1100-4c00-9cb6-a9674316b36d

395815558-c66a6a25-37fb-47a6-80f3-b7d7ebe69f00

For clarity, no further core updates have reverted this issue and from this thread it appears this has been done by design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants