Filter selected entities in entities picker using includeEntities property (#22059)

* Filter selected entities in entities picker using includeEntities property

* Don't ignore other property when using include entities
This commit is contained in:
Paul Bottein
2024-09-23 17:55:13 +02:00
committed by GitHub
parent be02a8869f
commit f7f37c24e2
2 changed files with 18 additions and 34 deletions

View File

@@ -87,7 +87,7 @@ export class HaEntityPicker extends LitElement {
public includeUnitOfMeasurement?: string[];
/**
* List of allowed entities to show. Will ignore all other filters.
* List of allowed entities to show.
* @type {Array}
* @attr include-entities
*/
@@ -220,30 +220,13 @@ export class HaEntityPicker extends LitElement {
if (includeEntities) {
entityIds = entityIds.filter((entityId) =>
this.includeEntities!.includes(entityId)
includeEntities.includes(entityId)
);
return entityIds
.map((key) => {
const friendly_name = computeStateName(hass!.states[key]) || key;
return {
...hass!.states[key],
friendly_name,
strings: [key, friendly_name],
};
})
.sort((entityA, entityB) =>
caseInsensitiveStringCompare(
entityA.friendly_name,
entityB.friendly_name,
this.hass.locale.language
)
);
}
if (excludeEntities) {
entityIds = entityIds.filter(
(entityId) => !excludeEntities!.includes(entityId)
(entityId) => !excludeEntities.includes(entityId)
);
}