Avoid fetching logbook when there will never be entries (#7239)

This commit is contained in:
J. Nick Koston 2020-10-06 11:22:38 -05:00 committed by GitHub
parent 5937be695f
commit c2fba15fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import { HomeAssistant } from "../types";
import { UNAVAILABLE_STATES } from "./entity";
const LOGBOOK_LOCALIZE_PATH = "ui.components.logbook.messages";
export const CONTINUOUS_DOMAINS = ["proximity", "sensor"];
export interface LogbookEntry {
when: string;

View File

@ -13,7 +13,11 @@ import { computeStateDomain } from "../../common/entity/compute_state_domain";
import { throttle } from "../../common/util/throttle";
import "../../components/ha-circular-progress";
import "../../components/state-history-charts";
import { getLogbookData, LogbookEntry } from "../../data/logbook";
import {
CONTINUOUS_DOMAINS,
getLogbookData,
LogbookEntry,
} from "../../data/logbook";
import "../../panels/logbook/ha-logbook";
import { haStyle, haStyleScrollbar } from "../../resources/styles";
import { HomeAssistant } from "../../types";
@ -40,7 +44,12 @@ export class MoreInfoLogbook extends LitElement {
}
const stateObj = this.hass.states[this.entityId];
if (!stateObj) {
if (!stateObj || stateObj.attributes.unit_of_measurement) {
return html``;
}
const domain = computeStateDomain(stateObj);
if (CONTINUOUS_DOMAINS.includes(domain)) {
return html``;
}
@ -155,9 +164,9 @@ export class MoreInfoLogbook extends LitElement {
overflow: auto;
}
@media all and (max-width: 450px), all and (max-height: 500px) {
ha-logbook {
max-height: unset;
}
ha-logbook {
max-height: unset;
}
}
ha-circular-progress {
display: flex;