Target picker fix entities count for labels (#27603)

This commit is contained in:
Wendelin
2025-10-23 15:53:48 +02:00
committed by GitHub
parent e48918442c
commit e9ca9bb781
2 changed files with 54 additions and 68 deletions

View File

@@ -162,11 +162,12 @@ export class HaTargetPickerItemRow extends LitElement {
<div slot="headline">${name}</div>
${context && !this.hideContext
? html`<span slot="supporting-text">${context}</span>`
: this._domainName && this.subEntry
? html`<span slot="supporting-text" class="domain"
>${this._domainName}</span
>`
: nothing}
: nothing}
${this._domainName && this.subEntry
? html`<span slot="supporting-text" class="domain"
>${this._domainName}</span
>`
: nothing}
${!this.subEntry && entries && showEntities
? html`
<div slot="end" class="summary">
@@ -231,9 +232,11 @@ export class HaTargetPickerItemRow extends LitElement {
const rows1 =
(nextType === "area"
? entries?.referenced_areas
: nextType === "device"
: nextType === "device" && this.type !== "label"
? entries?.referenced_devices
: entries?.referenced_entities) || [];
: this.type !== "label"
? entries?.referenced_entities
: []) || [];
const devicesInAreas = [] as string[];
@@ -284,9 +287,13 @@ export class HaTargetPickerItemRow extends LitElement {
const entityRows =
this.type === "label" && entries
? entries.referenced_entities.filter((entity_id) =>
this.hass.entities[entity_id].labels.includes(this.itemId)
)
? entries.referenced_entities.filter((entity_id) => {
const entity = this.hass.entities[entity_id];
return (
entity.labels.includes(this.itemId) &&
!entries.referenced_devices.includes(entity.device_id || "")
);
})
: nextType === "device" && entries
? entries.referenced_entities.filter(
(entity_id) =>
@@ -412,7 +419,6 @@ export class HaTargetPickerItemRow extends LitElement {
const device = this.hass.devices[device_id];
if (
!hiddenAreaIds.includes(device.area_id || "") &&
(this.type !== "label" || device.labels.includes(this.itemId)) &&
deviceMeetsFilter(
device,
this.hass.entities,
@@ -669,6 +675,14 @@ export class HaTargetPickerItemRow extends LitElement {
button.link:focus {
text-decoration: underline;
}
.domain {
width: fit-content;
border-radius: var(--ha-border-radius-md);
background-color: var(--ha-color-fill-neutral-quiet-resting);
padding: var(--ha-space-1);
font-family: var(--ha-font-family-code);
}
`,
];
}