diff --git a/README.md b/README.md index 1b8b05e..dbb961d 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,13 @@ Visit the [issues](https://github.com/AalianKhan/mushroom-strategy/issues/new/ch [sponsorBadge]: https://img.shields.io/badge/Sponsor_him-%E2%9D%A4-%23db61a2.svg?&logo=github&color=%23fe8e86 -[releaseBadge]: https://img.shields.io/badge/Release-v2.0.3-blue +[releaseBadge]: https://img.shields.io/badge/Release-v2.1.0-blue [hacsUrl]: https://hacs.xyz -[releaseUrl]: https://github.com/AalianKhan/mushroom-strategy/releases/tag/v2.0.3 +[releaseUrl]: https://github.com/AalianKhan/mushroom-strategy/releases/tag/v2.1.0 [mushroomUrl]: https://github.com/piitaya/lovelace-mushroom diff --git a/package-lock.json b/package-lock.json index bd504b7..1dc4cfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mushroom-strategy", - "version": "2.0.3", + "version": "2.1.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 9f259fe..9388491 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mushroom-strategy", - "version": "2.0.3", + "version": "2.1.0", "description": "Automatically create a dashboard using Mushroom cards", "keywords": [ "strategy", diff --git a/src/configurationDefaults.ts b/src/configurationDefaults.ts index 77dd892..d5366b3 100644 --- a/src/configurationDefaults.ts +++ b/src/configurationDefaults.ts @@ -16,6 +16,9 @@ export const configurationDefaults: StrategyDefaults = { }, debug: false, domains: { + _: { + hide_config_entities: false, + }, default: { title: "Miscellaneous", showControls: false, diff --git a/src/mushroom-strategy.ts b/src/mushroom-strategy.ts index 61cd84a..21af6c0 100644 --- a/src/mushroom-strategy.ts +++ b/src/mushroom-strategy.ts @@ -113,6 +113,9 @@ class MushroomStrategy extends HTMLTemplateElement { domainCards = await import(`./cards/${className}`).then(cardModule => { let domainCards = []; const entities = Helper.getDeviceEntities(area, domain); + let configEntityHidden = + Helper.strategyOptions.domains[domain ?? "_"].hide_config_entities + || Helper.strategyOptions.domains["_"].hide_config_entities; // Set the target for controller cards to entities without an area. if (area.area_id === "undisclosed") { @@ -175,9 +178,17 @@ class MushroomStrategy extends HTMLTemplateElement { deviceOptions = Helper.strategyOptions.card_options?.[entity.device_id]; } - if (!cardOptions?.hidden && !deviceOptions?.hidden) { - domainCards.push(new cardModule[className](entity, cardOptions).getCard()); + // Don't include the entity if hidden in the strategy options. + if (cardOptions?.hidden || deviceOptions?.hidden) { + continue; } + + // Don't include the config-entity if hidden in the strategy options. + if (entity.entity_category === "config" && configEntityHidden) { + continue; + } + + domainCards.push(new cardModule[className](entity, cardOptions).getCard()); } if (domain === "binary_sensor") { @@ -246,9 +257,17 @@ class MushroomStrategy extends HTMLTemplateElement { let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id]; let deviceOptions = Helper.strategyOptions.card_options?.[entity.device_id ?? "null"]; - if (!cardOptions?.hidden && !deviceOptions?.hidden) { - miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard()); + // Don't include the entity if hidden in the strategy options. + if (cardOptions?.hidden || deviceOptions?.hidden) { + continue; } + + // Don't include the config-entity if hidden in the strategy options + if (entity.entity_category === "config" && Helper.strategyOptions.domains["_"].hide_config_entities) { + continue; + } + + miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard()); } return miscellaneousCards; @@ -273,7 +292,7 @@ class MushroomStrategy extends HTMLTemplateElement { customElements.define("ll-strategy-mushroom-strategy", MushroomStrategy); -const version = "v2.0.3"; +const version = "v2.1.0"; console.info( "%c Mushroom Strategy %c ".concat(version, " "), "color: white; background: coral; font-weight: 700;", "color: coral; background: white; font-weight: 700;" diff --git a/src/types/strategy/generic.ts b/src/types/strategy/generic.ts index a4532c2..821d5fc 100644 --- a/src/types/strategy/generic.ts +++ b/src/types/strategy/generic.ts @@ -36,10 +36,13 @@ export namespace generic { * * @property {number} [order] Ordering position of the entity in the list of available views. * @property {boolean} [hidden] True if the entity should be hidden from the dashboard. + * @property {boolean} [hide_config_entities] True if the entity's categorie is "config" and should be hidden from the + * dashboard. */ export interface DomainConfig extends Partial { hidden?: boolean; order?: number; + hide_config_entities?: boolean } /** diff --git a/src/views/AbstractView.ts b/src/views/AbstractView.ts index b1a6a55..497cdaa 100644 --- a/src/views/AbstractView.ts +++ b/src/views/AbstractView.ts @@ -69,6 +69,9 @@ abstract class AbstractView { */ async createViewCards(): Promise<(StackCardConfig | TitleCardConfig)[]> { const viewCards: LovelaceCardConfig[] = []; + const configEntityHidden = + Helper.strategyOptions.domains[this.#domain ?? "_"].hide_config_entities + || Helper.strategyOptions.domains["_"].hide_config_entities; // Create cards for each area. for (const area of Helper.areas) { @@ -98,6 +101,10 @@ abstract class AbstractView { continue; } + if (entity.entity_category === "config" && configEntityHidden) { + continue; + } + areaCards.push(new cardModule[className](entity, cardOptions).getCard()); }