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

View File

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