Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/dialogs/more-info/ha-more-info-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
);
}
Expand Down
27 changes: 19 additions & 8 deletions src/dialogs/more-info/ha-more-info-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down