Use entity format state if only one entity for that domain in the area card (#25964)

Use entity format state if only one entity is area card
This commit is contained in:
Paul Bottein 2025-06-27 17:41:58 +02:00 committed by GitHub
parent 22c798c9d6
commit 9d8a5b366e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -348,6 +348,14 @@ export class HuiAreaCard extends LitElement implements LovelaceCard {
return undefined;
}
// If only one entity, return its formatted state
if (entities.length === 1) {
const stateObj = entities[0];
return isUnavailableState(stateObj.state)
? ""
: this.hass.formatEntityState(stateObj);
}
// Use the first entity's unit_of_measurement for formatting
const uom = entities.find(
(entity) => entity.attributes.unit_of_measurement