From 24688ba18e4167f092189e82adc1ff200b1699cb Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 7 Jul 2022 14:58:51 +0200 Subject: [PATCH] fix reload history when no selection made (#13137) --- src/panels/history/ha-panel-history.ts | 34 +++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/panels/history/ha-panel-history.ts b/src/panels/history/ha-panel-history.ts index 135620f5ed..d750ba5143 100644 --- a/src/panels/history/ha-panel-history.ts +++ b/src/panels/history/ha-panel-history.ts @@ -121,7 +121,7 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { : ""} @@ -254,10 +254,14 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { } private async _getHistory() { + if (!this._targetPickerValue) { + return; + } this._isLoading = true; const entityIds = this._getEntityIds(); if (entityIds === undefined) { + this._isLoading = false; this._stateHistory = undefined; return; } @@ -267,20 +271,22 @@ class HaPanelHistory extends SubscribeMixin(LitElement) { this._stateHistory = []; return; } + try { + const dateHistory = await fetchDateWS( + this.hass, + this._startDate, + this._endDate, + entityIds + ); - const dateHistory = await fetchDateWS( - this.hass, - this._startDate, - this._endDate, - entityIds - ); - - this._stateHistory = computeHistory( - this.hass, - dateHistory, - this.hass.localize - ); - this._isLoading = false; + this._stateHistory = computeHistory( + this.hass, + dateHistory, + this.hass.localize + ); + } finally { + this._isLoading = false; + } } private _getEntityIds(): string[] | undefined {