mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 18:36:35 +00:00
Guard for non numeric states (#10775)
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
parent
e99f20c4f3
commit
46a9e36516
@ -188,7 +188,10 @@ export class HuiAreaCard
|
|||||||
}
|
}
|
||||||
let uom;
|
let uom;
|
||||||
const values = entities.filter((entity) => {
|
const values = entities.filter((entity) => {
|
||||||
if (!entity.attributes.unit_of_measurement) {
|
if (
|
||||||
|
!entity.attributes.unit_of_measurement ||
|
||||||
|
isNaN(Number(entity.state))
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!uom) {
|
if (!uom) {
|
||||||
@ -200,7 +203,10 @@ export class HuiAreaCard
|
|||||||
if (!values.length) {
|
if (!values.length) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const sum = values.reduce((a, b) => a + Number(b.state), 0);
|
const sum = values.reduce(
|
||||||
|
(total, entity) => total + Number(entity.state),
|
||||||
|
0
|
||||||
|
);
|
||||||
return `${formatNumber(sum / values.length, this.hass!.locale, {
|
return `${formatNumber(sum / values.length, this.hass!.locale, {
|
||||||
maximumFractionDigits: 1,
|
maximumFractionDigits: 1,
|
||||||
})} ${uom}`;
|
})} ${uom}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user