From ba213bf11cd69b0b9237994b70d13e583ebd0a69 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 24 Dec 2025 01:08:35 -0800 Subject: [PATCH] Don't set history redraw timer when not connected (#28679) --- src/panels/lovelace/cards/hui-history-graph-card.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panels/lovelace/cards/hui-history-graph-card.ts b/src/panels/lovelace/cards/hui-history-graph-card.ts index a9b4d52a1b..50e4e59ce0 100644 --- a/src/panels/lovelace/cards/hui-history-graph-card.ts +++ b/src/panels/lovelace/cards/hui-history-graph-card.ts @@ -135,6 +135,10 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard { const { numeric_device_classes: sensorNumericDeviceClasses } = await getSensorNumericDeviceClasses(this.hass!); + if (!this.isConnected) { + return; // Skip subscribe if we already disconnected while awaiting + } + this._subscribed = subscribeHistoryStatesTimeWindow( this.hass!, (combinedHistory) => { @@ -212,7 +216,9 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard { private _setRedrawTimer() { // redraw the graph every minute to update the time axis clearInterval(this._interval); - this._interval = window.setInterval(() => this._redrawGraph(), 1000 * 60); + if (this.isConnected) { + this._interval = window.setInterval(() => this._redrawGraph(), 1000 * 60); + } } private _unsubscribeHistory() {