mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Avoid fetching logbook data instead in addition to not displaying it (#7427)
Co-authored-by: Zack Barett <zackbarett@hey.com>
This commit is contained in:
parent
7428731eac
commit
eceed4ed74
@ -38,6 +38,7 @@ import { showConfirmationDialog } from "../generic/show-dialog-box";
|
|||||||
import "./ha-more-info-history";
|
import "./ha-more-info-history";
|
||||||
import "./ha-more-info-logbook";
|
import "./ha-more-info-logbook";
|
||||||
import "./controls/more-info-default";
|
import "./controls/more-info-default";
|
||||||
|
import { CONTINUOUS_DOMAINS } from "../../data/logbook";
|
||||||
|
|
||||||
const DOMAINS_NO_INFO = ["camera", "configurator"];
|
const DOMAINS_NO_INFO = ["camera", "configurator"];
|
||||||
/**
|
/**
|
||||||
@ -169,7 +170,8 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
</ha-header-bar>
|
</ha-header-bar>
|
||||||
${DOMAINS_WITH_MORE_INFO.includes(domain) &&
|
${DOMAINS_WITH_MORE_INFO.includes(domain) &&
|
||||||
this._computeShowHistoryComponent(entityId)
|
(this._computeShowHistoryComponent(entityId) ||
|
||||||
|
this._computeShowLogBookComponent(entityId))
|
||||||
? html`
|
? html`
|
||||||
<mwc-tab-bar
|
<mwc-tab-bar
|
||||||
.activeIndex=${this._currTabIndex}
|
.activeIndex=${this._currTabIndex}
|
||||||
@ -206,13 +208,16 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
!this._computeShowHistoryComponent(entityId)
|
!this._computeShowHistoryComponent(entityId)
|
||||||
? ""
|
? ""
|
||||||
: html`<ha-more-info-history
|
: html`<ha-more-info-history
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.entityId=${this._entityId}
|
.entityId=${this._entityId}
|
||||||
></ha-more-info-history>
|
></ha-more-info-history>`}
|
||||||
<ha-more-info-logbook
|
${DOMAINS_WITH_MORE_INFO.includes(domain) ||
|
||||||
.hass=${this.hass}
|
!this._computeShowLogBookComponent(entityId)
|
||||||
.entityId=${this._entityId}
|
? ""
|
||||||
></ha-more-info-logbook>`}
|
: html`<ha-more-info-logbook
|
||||||
|
.hass=${this.hass}
|
||||||
|
.entityId=${this._entityId}
|
||||||
|
></ha-more-info-logbook>`}
|
||||||
${this._moreInfoType
|
${this._moreInfoType
|
||||||
? dynamicElement(this._moreInfoType, {
|
? dynamicElement(this._moreInfoType, {
|
||||||
hass: this.hass,
|
hass: this.hass,
|
||||||
@ -264,12 +269,32 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
|
|
||||||
private _computeShowHistoryComponent(entityId) {
|
private _computeShowHistoryComponent(entityId) {
|
||||||
return (
|
return (
|
||||||
(isComponentLoaded(this.hass, "history") ||
|
isComponentLoaded(this.hass, "history") &&
|
||||||
isComponentLoaded(this.hass, "logbook")) &&
|
|
||||||
!DOMAINS_MORE_INFO_NO_HISTORY.includes(computeDomain(entityId))
|
!DOMAINS_MORE_INFO_NO_HISTORY.includes(computeDomain(entityId))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _computeShowLogBookComponent(entityId): boolean {
|
||||||
|
if (!isComponentLoaded(this.hass, "logbook")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stateObj = this.hass.states[entityId];
|
||||||
|
if (!stateObj || stateObj.attributes.unit_of_measurement) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const domain = computeDomain(entityId);
|
||||||
|
if (
|
||||||
|
CONTINUOUS_DOMAINS.includes(domain) ||
|
||||||
|
DOMAINS_MORE_INFO_NO_HISTORY.includes(domain)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private _removeEntity() {
|
private _removeEntity() {
|
||||||
const entityId = this._entityId!;
|
const entityId = this._entityId!;
|
||||||
showConfirmationDialog(this, {
|
showConfirmationDialog(this, {
|
||||||
|
@ -13,11 +13,7 @@ import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
|||||||
import { throttle } from "../../common/util/throttle";
|
import { throttle } from "../../common/util/throttle";
|
||||||
import "../../components/ha-circular-progress";
|
import "../../components/ha-circular-progress";
|
||||||
import "../../components/state-history-charts";
|
import "../../components/state-history-charts";
|
||||||
import {
|
import { getLogbookData, LogbookEntry } from "../../data/logbook";
|
||||||
CONTINUOUS_DOMAINS,
|
|
||||||
getLogbookData,
|
|
||||||
LogbookEntry,
|
|
||||||
} from "../../data/logbook";
|
|
||||||
import "../../panels/logbook/ha-logbook";
|
import "../../panels/logbook/ha-logbook";
|
||||||
import { haStyle, haStyleScrollbar } from "../../resources/styles";
|
import { haStyle, haStyleScrollbar } from "../../resources/styles";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
@ -44,12 +40,7 @@ export class MoreInfoLogbook extends LitElement {
|
|||||||
}
|
}
|
||||||
const stateObj = this.hass.states[this.entityId];
|
const stateObj = this.hass.states[this.entityId];
|
||||||
|
|
||||||
if (!stateObj || stateObj.attributes.unit_of_measurement) {
|
if (!stateObj) {
|
||||||
return html``;
|
|
||||||
}
|
|
||||||
|
|
||||||
const domain = computeStateDomain(stateObj);
|
|
||||||
if (CONTINUOUS_DOMAINS.includes(domain)) {
|
|
||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user