From ee32e62dfb3190544094f38bd6b796ede886ffb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20F=C3=A9lix?= Date: Tue, 25 Jul 2023 11:02:16 +0100 Subject: [PATCH] fix: :bug: no decimals for individual secondary --- src/power-flow-card-plus.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/power-flow-card-plus.ts b/src/power-flow-card-plus.ts index b3af81f..d4ba66c 100644 --- a/src/power-flow-card-plus.ts +++ b/src/power-flow-card-plus.ts @@ -209,7 +209,7 @@ export class PowerFlowCardPlus extends LitElement { const valueInNumber = Number(value); const isKW = unit === undefined && valueInNumber >= this._config!.watt_threshold; const v = formatNumber( - isKW ? round(valueInNumber / 1000, this._config!.kw_decimals) : round(valueInNumber, decimals ?? this._config!.w_decimals), + isKW ? round(valueInNumber / 1000, decimals ?? this._config!.kw_decimals) : round(valueInNumber, decimals ?? this._config!.w_decimals), this.hass.locale ); return `${v}${unitWhiteSpace === false ? "" : " "}${unit || (isKW ? "kW" : "W")}`; @@ -436,6 +436,7 @@ export class PowerFlowCardPlus extends LitElement { unit_white_space: entities[field]?.secondary_info?.unit_white_space, displayZero: entities[field]?.secondary_info?.display_zero, displayZeroTolerance: entities[field]?.secondary_info?.display_zero_tolerance, + decimals: entities[field]?.secondary_info?.decimals, }, }); @@ -1065,7 +1066,12 @@ export class PowerFlowCardPlus extends LitElement { const individualSecondarySpan = (individual: Individual, key: string) => { const templateResult: string = templatesObj[`${key}Secondary`]; const value = individual.secondary.has - ? this.displayValue(individual.secondary.state, individual.secondary.unit, individual.secondary.unit_white_space) + ? this.displayValue( + individual.secondary.state, + individual.secondary.unit, + individual.secondary.unit_white_space, + individual.secondary.decimals + ) : undefined; const passesDisplayZeroCheck = individual.secondary.displayZero !== false ||