From 72e6c729c911e6c8918df8ac2787c5d059ed4bd6 Mon Sep 17 00:00:00 2001 From: Zack Arnett Date: Wed, 9 Sep 2020 16:08:26 -0500 Subject: [PATCH] only get log book data from last time --- src/dialogs/more-info/ha-more-info-history.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dialogs/more-info/ha-more-info-history.ts b/src/dialogs/more-info/ha-more-info-history.ts index 8e2cb6c3ed..192f48f000 100644 --- a/src/dialogs/more-info/ha-more-info-history.ts +++ b/src/dialogs/more-info/ha-more-info-history.ts @@ -33,6 +33,8 @@ export class MoreInfoHistory extends LitElement { private _historyRefreshInterval?: number; + private _lastLogbookDate?: Date; + protected render(): TemplateResult { if (!this.entityId) { return html``; @@ -88,6 +90,7 @@ export class MoreInfoHistory extends LitElement { if (changedProps.has("entityId")) { this._stateHistory = undefined; this._entries = undefined; + this._lastLogbookDate = undefined; this._getStateHistory(); this._getLogBookData(); @@ -115,15 +118,20 @@ export class MoreInfoHistory extends LitElement { } private async _getLogBookData() { - const yesterday = new Date(new Date().getTime() - 24 * 60 * 60 * 1000); + const lastDate = + this._lastLogbookDate || + new Date(new Date().getTime() - 24 * 60 * 60 * 1000); const now = new Date(); + this._entries = await getLogbookData( this.hass, - yesterday.toISOString(), + lastDate.toISOString(), now.toISOString(), this.entityId, true ); + + this._lastLogbookDate = now; } private _fetchPersonNames() {