mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-14 23:18:21 +00:00
Entity card: fix unit for monetary (#29406)
* fix unit for monetary * fix for span * formatEntityStateToParts() does not return "order" * get unit from formatEntityStateToParts() * resolving conflicts * resolving conflicts * some styling
This commit is contained in:
@@ -224,7 +224,11 @@ export class HaStateLabelBadge extends LitElement {
|
||||
if (domain === "timer") {
|
||||
return secondsToDuration(_timerTimeRemaining);
|
||||
}
|
||||
return entityState.attributes.unit_of_measurement || null;
|
||||
return (
|
||||
this.hass!.formatEntityStateToParts(entityState).find(
|
||||
(part) => part.type === "unit"
|
||||
)?.value || null
|
||||
);
|
||||
}
|
||||
|
||||
private _clearInterval() {
|
||||
|
||||
@@ -130,9 +130,9 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
|
||||
) {
|
||||
unit = this._config.unit;
|
||||
if (!unit) {
|
||||
if (!this._config.attribute)
|
||||
unit = stateObj.attributes.unit_of_measurement;
|
||||
else {
|
||||
if (!this._config.attribute) {
|
||||
unit = stateParts.find((part) => part.type === "unit")?.value;
|
||||
} else {
|
||||
const parts = this.hass.formatEntityAttributeValueToParts(
|
||||
stateObj,
|
||||
this._config.attribute
|
||||
|
||||
Reference in New Issue
Block a user