mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
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:
parent
22c798c9d6
commit
9d8a5b366e
@ -348,6 +348,14 @@ export class HuiAreaCard extends LitElement implements LovelaceCard {
|
|||||||
return undefined;
|
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
|
// Use the first entity's unit_of_measurement for formatting
|
||||||
const uom = entities.find(
|
const uom = entities.find(
|
||||||
(entity) => entity.attributes.unit_of_measurement
|
(entity) => entity.attributes.unit_of_measurement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user