Fix more info for disabled entity (#15641)

This commit is contained in:
Paul Bottein 2023-03-01 10:29:19 +01:00 committed by GitHub
parent a5541996d7
commit e3b797e85c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -214,7 +214,7 @@ export class MoreInfoDialog extends LitElement {
return null;
}
const entityId = this._entityId;
const stateObj = this.hass.states[entityId];
const stateObj = this.hass.states[entityId] as HassEntity | undefined;
const domain = computeDomain(entityId);
const name = (stateObj && computeStateName(stateObj)) || entityId;
@ -226,6 +226,7 @@ export class MoreInfoDialog extends LitElement {
const title = this._childView?.viewTitle ?? name;
const isInfoView = this._currView === "info" && !this._childView;
const isNewMoreInfo = stateObj && computeShowNewMoreInfo(stateObj);
return html`
<ha-dialog open @closed=${this.closeDialog} .heading=${title} hideActions>
@ -251,7 +252,7 @@ export class MoreInfoDialog extends LitElement {
)}
></ha-icon-button-prev>
`}
${!isInfoView || !computeShowNewMoreInfo(stateObj)
${!isInfoView || !isNewMoreInfo
? html`<div
slot="title"
class="main-title"

View File

@ -1,3 +1,4 @@
import { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import { computeDomain } from "../../common/entity/compute_domain";
@ -21,10 +22,10 @@ export class MoreInfoInfo extends LitElement {
protected render() {
const entityId = this.entityId;
const stateObj = this.hass.states[entityId];
const stateObj = this.hass.states[entityId] as HassEntity | undefined;
const entityRegObj = this.hass.entities[entityId];
const domain = computeDomain(entityId);
const newMoreInfo = computeShowNewMoreInfo(stateObj);
const isNewMoreInfo = stateObj && computeShowNewMoreInfo(stateObj);
return html`
<div class="container" data-domain=${domain}>
@ -46,7 +47,7 @@ export class MoreInfoInfo extends LitElement {
</ha-alert>`
: ""}
<div class="content">
${DOMAINS_NO_INFO.includes(domain) || computeShowNewMoreInfo(stateObj)
${DOMAINS_NO_INFO.includes(domain) || isNewMoreInfo
? ""
: html`
<state-card-content
@ -70,7 +71,7 @@ export class MoreInfoInfo extends LitElement {
.entityId=${this.entityId}
></ha-more-info-logbook>`}
<more-info-content
?full-height=${newMoreInfo}
?full-height=${isNewMoreInfo}
.stateObj=${stateObj}
.hass=${this.hass}
></more-info-content>