From 0242fbc6f887308cd98fbdb66f27dfc17f02df22 Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Tue, 29 Apr 2025 07:24:49 +0200 Subject: [PATCH] Guard against unknown entities in automation compare functions (#25213) Guard against unknown entities --- src/data/device_automation.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/data/device_automation.ts b/src/data/device_automation.ts index e64300a5aa..9bc011a591 100644 --- a/src/data/device_automation.ts +++ b/src/data/device_automation.ts @@ -167,10 +167,18 @@ const compareEntityIdWithEntityRegId = ( return false; } if (entityIdA.includes(".")) { - entityIdA = entityRegistryByEntityId(entityRegistry)[entityIdA].id; + const entityA = entityRegistryByEntityId(entityRegistry)[entityIdA]; + if (!entityA) { + return false; + } + entityIdA = entityA.id; } if (entityIdB.includes(".")) { - entityIdB = entityRegistryByEntityId(entityRegistry)[entityIdB].id; + const entityB = entityRegistryByEntityId(entityRegistry)[entityIdB]; + if (!entityB) { + return false; + } + entityIdB = entityB.id; } return entityIdA === entityIdB; };