Handle disabled entities in multi select label (#20371)

This commit is contained in:
Bram Kragten 2024-04-03 14:40:48 +02:00 committed by GitHub
parent 1a6d96cf3a
commit 3b5b3f3bb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1029,14 +1029,18 @@ ${
const action = ev.currentTarget.action; const action = ev.currentTarget.action;
const promises: Promise<UpdateEntityRegistryEntryResult>[] = []; const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
this._selected.forEach((entityId) => { this._selected.forEach((entityId) => {
const entityReg =
this.hass.entities[entityId] ||
this._entities.find((entReg) => entReg.entity_id === entityId);
if (!entityReg) {
return;
}
promises.push( promises.push(
updateEntityRegistryEntry(this.hass, entityId, { updateEntityRegistryEntry(this.hass, entityId, {
labels: labels:
action === "add" action === "add"
? this.hass.entities[entityId].labels.concat(label) ? entityReg.labels.concat(label)
: this.hass.entities[entityId].labels.filter( : entityReg.labels.filter((lbl) => lbl !== label),
(lbl) => lbl !== label
),
}) })
); );
}); });