From b9b590a262ee3f70999351498c729c3c03a50520 Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Wed, 25 May 2022 17:11:37 +0300 Subject: [PATCH] fix remaining state #2 --- src/ha-sankey-chart.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ha-sankey-chart.ts b/src/ha-sankey-chart.ts index 2f13341..b26a1f6 100644 --- a/src/ha-sankey-chart.ts +++ b/src/ha-sankey-chart.ts @@ -254,10 +254,14 @@ export class SankeyChart extends LitElement { }) .map(entityConf => { const entity = this._getEntityState(entityConf); - const {state, unit_of_measurement} = this._normalizeStateValue( - entityConf.accountedState ? Number(entity.state) - entityConf.accountedState : Number(entity.state), + // eslint-disable-next-line prefer-const + let {state, unit_of_measurement} = this._normalizeStateValue( + Number(entity.state), entity.attributes.unit_of_measurement ); + if (entityConf.accountedState) { + state -= entityConf.accountedState + } total += state; if (extraEntities[sectionIndex]) { extraEntities[sectionIndex].some(e => {