1
0
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:
ildar170975
2026-02-10 16:09:43 +03:00
committed by GitHub
parent 3753c7d313
commit c68bcc5b32
2 changed files with 8 additions and 4 deletions

View File

@@ -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() {

View File

@@ -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