From 0e07d56abd3b957a6a6a84aae1dd9054c4d743a6 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 10 Sep 2020 12:13:15 +0200 Subject: [PATCH] Check if history and logbook are loaded --- src/dialogs/more-info/ha-more-info-dialog.ts | 3 ++- src/dialogs/more-info/ha-more-info-history.ts | 27 +++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/dialogs/more-info/ha-more-info-dialog.ts b/src/dialogs/more-info/ha-more-info-dialog.ts index 15d71e694fca..f5beadea902a 100644 --- a/src/dialogs/more-info/ha-more-info-dialog.ts +++ b/src/dialogs/more-info/ha-more-info-dialog.ts @@ -223,7 +223,8 @@ export class MoreInfoDialog extends LitElement { private _computeShowHistoryComponent(entityId) { return ( - isComponentLoaded(this.hass, "history") && + (isComponentLoaded(this.hass, "history") || + isComponentLoaded(this.hass, "logbook")) && !DOMAINS_MORE_INFO_NO_HISTORY.includes(computeDomain(entityId)) ); } diff --git a/src/dialogs/more-info/ha-more-info-history.ts b/src/dialogs/more-info/ha-more-info-history.ts index 50390b31a23d..4bc6781e44ea 100644 --- a/src/dialogs/more-info/ha-more-info-history.ts +++ b/src/dialogs/more-info/ha-more-info-history.ts @@ -8,6 +8,7 @@ import { PropertyValues, TemplateResult, } from "lit-element"; +import { isComponentLoaded } from "../../common/config/is_component_loaded"; import { computeStateDomain } from "../../common/entity/compute_state_domain"; import "../../components/ha-circular-progress"; import "../../components/state-history-charts"; @@ -42,13 +43,16 @@ export class MoreInfoHistory extends LitElement { return html``; } - return html` - ${!this._entries + return html`${isComponentLoaded(this.hass, "history") + ? html`` + : ""} + ${isComponentLoaded(this.hass, "logbook") + ? !this._entries ? html` ${this.hass.localize("ui.components.logbook.entries_not_found")} - `}`; + ` + : ""} `; } protected firstUpdated(): void { @@ -97,6 +102,9 @@ export class MoreInfoHistory extends LitElement { } private async _getStateHistory(): Promise { + if (!isComponentLoaded(this.hass, "history")) { + return; + } this._stateHistory = await getRecentWithCache( this.hass!, this.entityId, @@ -111,6 +119,9 @@ export class MoreInfoHistory extends LitElement { } private async _getLogBookData() { + if (!isComponentLoaded(this.hass, "logbook")) { + return; + } const yesterday = new Date(new Date().getTime() - 24 * 60 * 60 * 1000); const now = new Date(); this._entries = await getLogbookData(