From f87d4a5ab6614c3b9f08930751a6a56d4138038e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 28 Jul 2021 10:46:51 -0700 Subject: [PATCH] If we have solar defined, always make sure sum is number so it shows placeholders (#9634) --- .../energy/hui-energy-distribution-card.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts b/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts index 78f1af3b55..960dbe752f 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-distribution-card.ts @@ -86,19 +86,21 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard { let totalSolarProduction: number | null = null; if (hasSolarProduction) { - totalSolarProduction = calculateStatisticsSumGrowth( - this._stats, - types.solar!.map((source) => source.stat_energy_from) - ); + totalSolarProduction = + calculateStatisticsSumGrowth( + this._stats, + types.solar!.map((source) => source.stat_energy_from) + ) || 0; } let productionReturnedToGrid: number | null = null; if (hasReturnToGrid) { - productionReturnedToGrid = calculateStatisticsSumGrowth( - this._stats, - types.grid![0].flow_to.map((flow) => flow.stat_energy_to) - ); + productionReturnedToGrid = + calculateStatisticsSumGrowth( + this._stats, + types.grid![0].flow_to.map((flow) => flow.stat_energy_to) + ) || 0; } const totalConsumption = @@ -191,7 +193,7 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard { : ""}${round(totalGridConsumption, 1)} kWh - ${productionReturnedToGrid + ${productionReturnedToGrid !== null ? html`