From 4cbb1274f62064425b7e1aa1b01113d5660ab45e Mon Sep 17 00:00:00 2001 From: DigiLive Date: Wed, 14 May 2025 08:36:37 +0200 Subject: [PATCH] Fix "Area not found" error If the card type for the undisclosed area is set to `HaAreaCard`, a card is shown with the message "Area not found". This is because it's not a real area and the type must be enforced to `default`. Closes #206 --- src/Registry.ts | 3 ++- src/cards/AreaCard.ts | 4 ++-- src/views/HomeView.ts | 4 ---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Registry.ts b/src/Registry.ts index a40df04..938d9cb 100644 --- a/src/Registry.ts +++ b/src/Registry.ts @@ -179,8 +179,9 @@ class Registry { return { ...area, ...Registry.strategyOptions.areas['_'], ...Registry.strategyOptions.areas?.[area.area_id] }; }); - // Ensure the custom configuration of the undisclosed area doesn't overwrite the area_id. + // Ensure the custom configuration of the undisclosed area doesn't overwrite the required property values. Registry.strategyOptions.areas.undisclosed.area_id = 'undisclosed'; + Registry.strategyOptions.areas.undisclosed.type = 'default'; // Remove hidden areas if configured as so and sort them by name. diff --git a/src/cards/AreaCard.ts b/src/cards/AreaCard.ts index 8028958..151946a 100644 --- a/src/cards/AreaCard.ts +++ b/src/cards/AreaCard.ts @@ -40,8 +40,8 @@ class AreaCard extends AbstractCard { configuration.tap_action.navigation_path = area.area_id; } - // Don't override the default card type if default is set in the strategy options. - if (customConfig && customConfig.type === 'default') { + // Don't override the card type if set differently in the strategy options. + if (customConfig) { customConfig = { ...customConfig, type: configuration.type }; } diff --git a/src/views/HomeView.ts b/src/views/HomeView.ts index ec2e707..9989b24 100644 --- a/src/views/HomeView.ts +++ b/src/views/HomeView.ts @@ -229,16 +229,12 @@ class HomeView extends AbstractView { const cardConfigurations: (TemplateCardConfig | AreaCardConfig)[] = []; - let onlyDefaultCards = true; - for (const area of Registry.areas) { const moduleName = Registry.strategyOptions.areas[area.area_id]?.type ?? Registry.strategyOptions.areas['_']?.type ?? 'default'; let AreaCard; - onlyDefaultCards = onlyDefaultCards && moduleName === 'default'; - try { AreaCard = (await import(`../cards/${moduleName}`)).default; } catch (e) {