Don't show members for legacy groups (#26179)

This commit is contained in:
Paul Bottein 2025-07-15 19:05:38 +02:00 committed by GitHub
parent 72a12a4ba4
commit 7db4693082
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@ import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { dynamicElement } from "../../common/dom/dynamic-element-directive"; import { dynamicElement } from "../../common/dom/dynamic-element-directive";
import { computeStateDomain } from "../../common/entity/compute_state_domain";
import "../../components/ha-badge"; import "../../components/ha-badge";
import type { ExtEntityRegistryEntry } from "../../data/entity_registry"; import type { ExtEntityRegistryEntry } from "../../data/entity_registry";
import type { TileCardConfig } from "../../panels/lovelace/cards/types"; import type { TileCardConfig } from "../../panels/lovelace/cards/types";
@ -45,8 +46,7 @@ class MoreInfoContent extends LitElement {
entry: this.entry, entry: this.entry,
editMode: this.editMode, editMode: this.editMode,
})} })}
${this.stateObj.attributes.entity_id && ${this._showEntityMembers(this.stateObj)
this.stateObj.attributes.entity_id.length
? html` ? html`
<hui-section <hui-section
.hass=${this.hass} .hass=${this.hass}
@ -60,6 +60,19 @@ class MoreInfoContent extends LitElement {
`; `;
} }
private _showEntityMembers(stateObj: HassEntity): boolean {
if (computeStateDomain(stateObj) === "group") {
// Don't show entity members for legacy groups as they already show
// the members in their more info dialog.
return false;
}
return (
stateObj.attributes &&
stateObj.attributes.entity_id &&
Array.isArray(stateObj.attributes.entity_id)
);
}
private _entitiesSectionConfig = memoizeOne((entityIds: string[]) => ({ private _entitiesSectionConfig = memoizeOne((entityIds: string[]) => ({
type: "grid", type: "grid",
cards: entityIds.map( cards: entityIds.map(