From 6f444c5c15fafd8038d1aec6dad04716144e9a5f Mon Sep 17 00:00:00 2001 From: w531t4 <41222371+w531t4@users.noreply.github.com> Date: Fri, 22 Nov 2024 05:50:19 -0500 Subject: [PATCH] Fix entity card added twice to view (#154) If not using the area of the entity's device, a card for this entity is added for the custom set area, as well as for the area of the entity's device. This change keeps the entity for the custom-set area or else for the area of the entity's device. --- src/Helper.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Helper.ts b/src/Helper.ts index d5daa53..16e93d0 100644 --- a/src/Helper.ts +++ b/src/Helper.ts @@ -400,7 +400,7 @@ class Helper { * Entities of which all the conditions below are met are kept: * 1. The entity is not hidden and is not disabled. * 2. The entity's domain matches the given domain. - * 3. Or/Neither the entity's linked device (if any) or/nor the entity itself is linked to the given area. + * 3. The entity itself or else the entity's linked device is linked to the given area. * (See variable areaMatch) * * @param {EntityRegistryEntry} entity The current hass entity to evaluate. @@ -423,9 +423,9 @@ class Helper { // nor the entity itself, neither the entity's linked device (if any) is linked to any area. ? !entity.area_id && (this.areaDeviceIds.includes(entity.device_id ?? "") || !entity.device_id) // Area is a hass entity; - // The entity's linked device or the entity itself is linked to the given area. - : this.areaDeviceIds.includes(entity.device_id ?? "") || entity.area_id === this.area.area_id; - + // The entity itself or the entity's device is linked to the given area. + // Note: entity.area_id is set to null when using device's area. + : entity.area_id === this.area.area_id || (!entity.area_id && this.areaDeviceIds.includes(entity.device_id ?? "")); return (entityUnhidden && domainMatches && entityLinked); }