diff --git a/src/panels/lovelace/cards/hui-entity-card.ts b/src/panels/lovelace/cards/hui-entity-card.ts index d08458068e..88cd9f4450 100644 --- a/src/panels/lovelace/cards/hui-entity-card.ts +++ b/src/panels/lovelace/cards/hui-entity-card.ts @@ -142,6 +142,10 @@ export class HuiEntityCard extends LitElement implements LovelaceCard { } } + const indexUnit = stateParts.findIndex((part) => part.type === "unit"); + const indexValue = stateParts.findIndex((part) => part.type === "value"); + const reversedOrder = indexUnit !== -1 && indexUnit < indexValue; + const name = computeLovelaceEntityName( this.hass, stateObj, @@ -190,7 +194,11 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
- ${"attribute" in this._config ? stateObj.attributes[this._config.attribute!] !== undefined ? html`` : this.hass.localize("state.default.unknown") : stateParts.find((part) => part.type === "value")?.value} - ${unit ? html`${unit}` : nothing} + >${unit + ? html`${unit}` + : nothing}