diff --git a/src/dialogs/more-info/ha-more-info-dialog.ts b/src/dialogs/more-info/ha-more-info-dialog.ts index a0c3378af6..10a4b1f15b 100644 --- a/src/dialogs/more-info/ha-more-info-dialog.ts +++ b/src/dialogs/more-info/ha-more-info-dialog.ts @@ -38,6 +38,7 @@ import { showConfirmationDialog } from "../generic/show-dialog-box"; import "./ha-more-info-history"; import "./ha-more-info-logbook"; import "./controls/more-info-default"; +import { CONTINUOUS_DOMAINS } from "../../data/logbook"; const DOMAINS_NO_INFO = ["camera", "configurator"]; /** @@ -169,7 +170,8 @@ export class MoreInfoDialog extends LitElement { : ""} ${DOMAINS_WITH_MORE_INFO.includes(domain) && - this._computeShowHistoryComponent(entityId) + (this._computeShowHistoryComponent(entityId) || + this._computeShowLogBookComponent(entityId)) ? html` - `} + .hass=${this.hass} + .entityId=${this._entityId} + >`} + ${DOMAINS_WITH_MORE_INFO.includes(domain) || + !this._computeShowLogBookComponent(entityId) + ? "" + : html``} ${this._moreInfoType ? dynamicElement(this._moreInfoType, { hass: this.hass, @@ -264,12 +269,32 @@ export class MoreInfoDialog extends LitElement { private _computeShowHistoryComponent(entityId) { return ( - (isComponentLoaded(this.hass, "history") || - isComponentLoaded(this.hass, "logbook")) && + isComponentLoaded(this.hass, "history") && !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() { const entityId = this._entityId!; showConfirmationDialog(this, { diff --git a/src/dialogs/more-info/ha-more-info-logbook.ts b/src/dialogs/more-info/ha-more-info-logbook.ts index a221fae68f..107636a7c0 100644 --- a/src/dialogs/more-info/ha-more-info-logbook.ts +++ b/src/dialogs/more-info/ha-more-info-logbook.ts @@ -13,11 +13,7 @@ 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 { - CONTINUOUS_DOMAINS, - getLogbookData, - LogbookEntry, -} from "../../data/logbook"; +import { getLogbookData, LogbookEntry } from "../../data/logbook"; import "../../panels/logbook/ha-logbook"; import { haStyle, haStyleScrollbar } from "../../resources/styles"; import { HomeAssistant } from "../../types"; @@ -44,12 +40,7 @@ export class MoreInfoLogbook extends LitElement { } const stateObj = this.hass.states[this.entityId]; - if (!stateObj || stateObj.attributes.unit_of_measurement) { - return html``; - } - - const domain = computeStateDomain(stateObj); - if (CONTINUOUS_DOMAINS.includes(domain)) { + if (!stateObj) { return html``; }