From 2982adbfa73876fb8119339d8f84f4ff1850d190 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 30 Jul 2021 21:57:27 +0200 Subject: [PATCH] Fix return compensation not being negative (#9654) --- .../lovelace/cards/energy/hui-energy-sources-table-card.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts b/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts index 44f4336609..83252fe9fe 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts @@ -202,7 +202,7 @@ export class HuiEnergySourcesTableCard flow.stat_cost || this._energyInfo!.cost_sensors[flow.stat_energy_from]; const cost = cost_stat - ? calculateStatisticSumGrowth(this._stats![cost_stat]) + ? calculateStatisticSumGrowth(this._stats![cost_stat]) || 0 : null; if (cost !== null) { totalCost += cost; @@ -260,7 +260,8 @@ export class HuiEnergySourcesTableCard flow.stat_compensation || this._energyInfo!.cost_sensors[flow.stat_energy_to]; const cost = cost_stat - ? calculateStatisticSumGrowth(this._stats![cost_stat]) + ? (calculateStatisticSumGrowth(this._stats![cost_stat]) || + 0) * -1 : null; if (cost !== null) { totalCost += cost;