Allow entity-filter-card to filter on other entity (#24396)

This commit is contained in:
karwosts 2025-02-25 13:37:31 -08:00 committed by GitHub
parent a048c36861
commit 3b272ae411
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -191,6 +191,9 @@ export function extractConditionEntityIds(
const entityIds = new Set<string>(); const entityIds = new Set<string>();
for (const condition of conditions) { for (const condition of conditions) {
if (condition.condition === "numeric_state") { if (condition.condition === "numeric_state") {
if (condition.entity) {
entityIds.add(condition.entity);
}
if ( if (
typeof condition.above === "string" && typeof condition.above === "string" &&
isValidEntityId(condition.above) isValidEntityId(condition.above)
@ -204,6 +207,9 @@ export function extractConditionEntityIds(
entityIds.add(condition.below); entityIds.add(condition.below);
} }
} else if (condition.condition === "state") { } else if (condition.condition === "state") {
if (condition.entity) {
entityIds.add(condition.entity);
}
[ [
...(ensureArray(condition.state) ?? []), ...(ensureArray(condition.state) ?? []),
...(ensureArray(condition.state_not) ?? []), ...(ensureArray(condition.state_not) ?? []),
@ -304,8 +310,8 @@ export function addEntityToCondition(
condition.condition === "numeric_state" condition.condition === "numeric_state"
) { ) {
return { return {
...condition,
entity: entityId, entity: entityId,
...condition,
}; };
} }
return condition; return condition;