From 4031d9cc782e16f277ef4b6f14ba46bbfd084132 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 28 Feb 2023 03:58:45 -0600 Subject: [PATCH] Avoid loading the whole entity registry for more info (#15627) --- src/dialogs/more-info/ha-more-info-info.ts | 25 ++++------------------ 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/dialogs/more-info/ha-more-info-info.ts b/src/dialogs/more-info/ha-more-info-info.ts index c7e9721ca7..b1b1ec7a2b 100644 --- a/src/dialogs/more-info/ha-more-info-info.ts +++ b/src/dialogs/more-info/ha-more-info-info.ts @@ -1,11 +1,6 @@ import { css, html, LitElement } from "lit"; -import { customElement, property, state } from "lit/decorators"; +import { customElement, property } from "lit/decorators"; import { computeDomain } from "../../common/entity/compute_domain"; -import { subscribeOne } from "../../common/util/subscribe-one"; -import { - EntityRegistryEntry, - subscribeEntityRegistry, -} from "../../data/entity_registry"; import type { HomeAssistant } from "../../types"; import { computeShowHistoryComponent, @@ -24,11 +19,10 @@ export class MoreInfoInfo extends LitElement { @property() public entityId!: string; - @state() private _entityEntry?: EntityRegistryEntry; - protected render() { const entityId = this.entityId; const stateObj = this.hass.states[entityId]; + const entityRegObj = this.hass.entities[entityId]; const domain = computeDomain(entityId); const newMoreInfo = computeShowNewMoreInfo(stateObj); @@ -41,12 +35,12 @@ export class MoreInfoInfo extends LitElement { )} ` : ""} - ${stateObj?.attributes.restored && this._entityEntry + ${stateObj?.attributes.restored && entityRegObj ? html` ${this.hass.localize( "ui.dialogs.more_info_control.restored.no_longer_provided", { - integration: this._entityEntry.platform, + integration: entityRegObj.platform, } )} ` @@ -86,17 +80,6 @@ export class MoreInfoInfo extends LitElement { `; } - protected firstUpdated(changedProps) { - super.firstUpdated(changedProps); - subscribeOne(this.hass.connection, subscribeEntityRegistry).then( - (entries) => { - this._entityEntry = entries.find( - (entry) => entry.entity_id === this.entityId - ); - } - ); - } - static get styles() { return css` .container {