If we have solar defined, always make sure sum is number so it shows placeholders (#9634)

This commit is contained in:
Paulus Schoutsen 2021-07-28 10:46:51 -07:00 committed by GitHub
parent 9c31b749d7
commit f87d4a5ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,19 +86,21 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard {
let totalSolarProduction: number | null = null; let totalSolarProduction: number | null = null;
if (hasSolarProduction) { if (hasSolarProduction) {
totalSolarProduction = calculateStatisticsSumGrowth( totalSolarProduction =
calculateStatisticsSumGrowth(
this._stats, this._stats,
types.solar!.map((source) => source.stat_energy_from) types.solar!.map((source) => source.stat_energy_from)
); ) || 0;
} }
let productionReturnedToGrid: number | null = null; let productionReturnedToGrid: number | null = null;
if (hasReturnToGrid) { if (hasReturnToGrid) {
productionReturnedToGrid = calculateStatisticsSumGrowth( productionReturnedToGrid =
calculateStatisticsSumGrowth(
this._stats, this._stats,
types.grid![0].flow_to.map((flow) => flow.stat_energy_to) types.grid![0].flow_to.map((flow) => flow.stat_energy_to)
); ) || 0;
} }
const totalConsumption = const totalConsumption =
@ -191,7 +193,7 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard {
: ""}${round(totalGridConsumption, 1)} : ""}${round(totalGridConsumption, 1)}
kWh kWh
</span> </span>
${productionReturnedToGrid ${productionReturnedToGrid !== null
? html`<span class="return"> ? html`<span class="return">
<ha-svg-icon <ha-svg-icon
class="small" class="small"