mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Check if history and logbook are loaded (#6908)
This commit is contained in:
parent
b0508f430e
commit
ce8ee569c4
@ -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))
|
||||
);
|
||||
}
|
||||
|
@ -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`<state-history-charts
|
||||
up-to-now
|
||||
.hass=${this.hass}
|
||||
.historyData=${this._stateHistory}
|
||||
.isLoadingData=${!this._stateHistory}
|
||||
></state-history-charts>
|
||||
${!this._entries
|
||||
return html`${isComponentLoaded(this.hass, "history")
|
||||
? html`<state-history-charts
|
||||
up-to-now
|
||||
.hass=${this.hass}
|
||||
.historyData=${this._stateHistory}
|
||||
.isLoadingData=${!this._stateHistory}
|
||||
></state-history-charts>`
|
||||
: ""}
|
||||
${isComponentLoaded(this.hass, "logbook")
|
||||
? !this._entries
|
||||
? html`
|
||||
<ha-circular-progress
|
||||
active
|
||||
@ -69,7 +73,8 @@ export class MoreInfoHistory extends LitElement {
|
||||
`
|
||||
: html`<div class="no-entries">
|
||||
${this.hass.localize("ui.components.logbook.entries_not_found")}
|
||||
</div>`}`;
|
||||
</div>`
|
||||
: ""} `;
|
||||
}
|
||||
|
||||
protected firstUpdated(): void {
|
||||
@ -97,6 +102,9 @@ export class MoreInfoHistory extends LitElement {
|
||||
}
|
||||
|
||||
private async _getStateHistory(): Promise<void> {
|
||||
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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user