mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Fix "unavailable" state in Area card (#25063)
* fix "unavailable" state * Show "-" for unavailable/undefined
This commit is contained in:
parent
11e4a9f056
commit
a099e65a9d
@ -384,7 +384,10 @@ export class HuiAreaCard
|
|||||||
areaSensorEntityId = area.humidity_entity_id;
|
areaSensorEntityId = area.humidity_entity_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const areaEntity = areaSensorEntityId
|
const areaEntity =
|
||||||
|
areaSensorEntityId &&
|
||||||
|
this.hass.states[areaSensorEntityId] &&
|
||||||
|
!isUnavailableState(this.hass.states[areaSensorEntityId].state)
|
||||||
? this.hass.states[areaSensorEntityId]
|
? this.hass.states[areaSensorEntityId]
|
||||||
: undefined;
|
: undefined;
|
||||||
if (
|
if (
|
||||||
@ -393,6 +396,10 @@ export class HuiAreaCard
|
|||||||
(entity) => entity.attributes.device_class === deviceClass
|
(entity) => entity.attributes.device_class === deviceClass
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
let value = areaEntity
|
||||||
|
? this.hass.formatEntityState(areaEntity)
|
||||||
|
: this._average(domain, deviceClass);
|
||||||
|
if (!value) value = "—";
|
||||||
sensors.push(html`
|
sensors.push(html`
|
||||||
<div class="sensor">
|
<div class="sensor">
|
||||||
<ha-domain-icon
|
<ha-domain-icon
|
||||||
@ -400,9 +407,7 @@ export class HuiAreaCard
|
|||||||
.domain=${domain}
|
.domain=${domain}
|
||||||
.deviceClass=${deviceClass}
|
.deviceClass=${deviceClass}
|
||||||
></ha-domain-icon>
|
></ha-domain-icon>
|
||||||
${areaEntity
|
${value}
|
||||||
? this.hass.formatEntityState(areaEntity)
|
|
||||||
: this._average(domain, deviceClass)}
|
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user