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

Entities with device_class: duration no longer displaying in human readable format #23338

Open
4 tasks done
craibo opened this issue Dec 19, 2024 · 8 comments
Open
4 tasks done

Comments

@craibo
Copy link

craibo commented Dec 19, 2024

Checklist

  • I have updated to the latest available Home Assistant version.
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser.
  • I have tried reproducing the issue in safe mode to rule out problems with unsupported custom resources.

Describe the issue you are experiencing

Since upgrading to core-2024.12.0 and future versions, entities with the device_class: duration, unit_of_measurement: s are no longer displaying on the dashboards in a human readable format.
6,317 seconds is being displayed as 6,317s. It was previously being displayed in a human readable format of 1:45:17

image

Describe the behavior you expected

Entities with a device_class: duration, unit_of_measurement: s should be displayed in a human readable format of H:MM:SS

eg. using device_class: duration, unit_of_measurement: s for the entity
value:75 should display as 1:15
value:6317 should display as 1:45:17

Steps to reproduce the issue

  1. Find an entity with device_class: duration and unit_of_measurement: s and a value greater then 60
  2. Add the entity to a dashboard
  3. The value will display in {value}s format instead of the human readable format

What version of Home Assistant Core has the issue?

core-2024.12.0

What was the last working version of Home Assistant Core?

core-2024.11.3

In which browser are you experiencing the issue with?

Chrome, Companion App, Brave

Which operating system are you using to run this browser?

Windows, MacOS, Android, iOS

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

@karwosts
Copy link
Contributor

karwosts commented Dec 19, 2024

This is new intended behavior, it is intended to be more customizable than the previous implementation.

If you want to see time in HH:MM format, change the unit_of_measurement for the entity to hours in the entity settings menu.
If you want to see time in MM:SS format, change the unit_of_measurement to minutes.

See: #23025

@craibo
Copy link
Author

craibo commented Dec 19, 2024

Hi @karwosts

Thanks for the explanation. I have added a comment to request that these changes be reverted.

The unit_of_measurement advises what the base value is provided in. By setting this manually there is no option to dynamically view durations that range between minutes, hours, days and are not consistent.

@karwosts
Copy link
Contributor

The unit of measurement selector in the UI does not have to be the base value of the sensor.

If user picks a different value there, the base value is converted to that unit for display.

@craibo
Copy link
Author

craibo commented Dec 20, 2024

Ok, that makes sense, I still believe by default the values should display dynamically in a human readable format and you can use the unit_of_measure enhancement to override this and use a fixed measurement.

@karwosts
Copy link
Contributor

Unfortunately there is no concept of a "default" here, UoM can be selected as days, hours, minutes, or seconds, but there's no option which is "none of these, do something dynamic".

There was mention of maybe doing something more with the display precision setting in the future, but that hasn't been acted on yet.

@craibo
Copy link
Author

craibo commented Dec 20, 2024

Ok, what would the fix be to support the users who are negatively affected by this change and don't have a way forward?

I tried to use the unit of measure setting and that is not available?
image

So we are left with dashboards of pretty unusable numbers at the moment. See craibo/ha_strava#189 for example.

FYI @piitaya

@karwosts
Copy link
Contributor

karwosts commented Dec 20, 2024

Can you share the attributes of that sensor.strava_0_10 (unit_of_measurement & device class?).

Surprised you don't see the unit_of_measurement selector there, I would have expected to see that.

      ${domain === "sensor" &&
      this._deviceClass &&
      stateObj?.attributes.unit_of_measurement &&
      this._sensorDeviceClassConvertibleUnits?.includes(
        stateObj?.attributes.unit_of_measurement
      )
        ? html`
            <ha-select
              .label=${this.hass.localize(
                "ui.dialogs.entity_registry.editor.unit_of_measurement"
              )}
              .value=${stateObj.attributes.unit_of_measurement}
              naturalMenuWidth
              fixedMenuPosition
              @selected=${this._unitChanged}
              @closed=${stopPropagation}
            >
              ${this._sensorDeviceClassConvertibleUnits.map(
                (unit: string) => html`
                  <ha-list-item .value=${unit}>${unit}</ha-list-item>
                `
              )}
            </ha-select>
          `
        : ""}

This is what I see for a duration sensor with unit_of_measurement: s

image

@craibo
Copy link
Author

craibo commented Dec 21, 2024

Here is the configuration of the sensor

Screenshot_20241221-204159.png

Screenshot_20241221-204756.png

Both parameters are set as you mentioned.

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

No branches or pull requests

2 participants