From 49a66961e2df6be6f162b96adb06f9fc553b6bce Mon Sep 17 00:00:00 2001
From: karwosts <32912880+karwosts@users.noreply.github.com>
Date: Tue, 26 Sep 2023 13:00:39 -0700
Subject: [PATCH] Fix adjust statistic dialog after a period of sensor
unavailability (#17934)
* Fix adjust statistic dialog after a period of sensor unavailability
* Remove fetching an unnecessary datapoint
---
.../dialog-statistics-adjust-sum.ts | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts b/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts
index 8dd31d35c0..b34769e44b 100644
--- a/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts
+++ b/src/panels/developer-tools/statistics/dialog-statistics-adjust-sum.ts
@@ -132,20 +132,20 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
if (!this._stats5min || !this._statsHour) {
stats = html`
No statistics found for this period.
`; } else { const data = - this._stats5min.length >= 2 ? this._stats5min : this._statsHour; + this._stats5min.length >= 1 ? this._stats5min : this._statsHour; const unit = getDisplayUnit( this.hass, this._params!.statistic.statistic_id, this._params!.statistic ); const rows: TemplateResult[] = []; - for (let i = 1; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { const stat = data[i]; - const growth = Math.round((stat.sum! - data[i - 1].sum!) * 100) / 100; + const growth = Math.round(stat.change! * 100) / 100; rows.push(html`