diff --git a/src/cards/AreaCard.ts b/src/cards/AreaCard.ts index fe28595..5054a99 100644 --- a/src/cards/AreaCard.ts +++ b/src/cards/AreaCard.ts @@ -22,7 +22,7 @@ class AreaCard extends AbstractCard { #defaultConfig: TemplateCardConfig = { type: "custom:mushroom-template-card", primary: undefined, - icon: "mdi:texture-box", + icon: "mdi:floor-plan", icon_color: "blue", tap_action: { action: "navigate", @@ -51,10 +51,16 @@ class AreaCard extends AbstractCard { // Initialize the default configuration. this.#defaultConfig.primary = area.name; + if (this.#defaultConfig.tap_action && ("navigation_path" in this.#defaultConfig.tap_action)) { this.#defaultConfig.tap_action.navigation_path = area.area_id; } + // Overwrite the default icon to the user-defined icon in hass. + if (area.icon) { + this.#defaultConfig.icon = area.icon; + } + this.config = Object.assign(this.config, this.#defaultConfig, options); } } diff --git a/src/configurationDefaults.ts b/src/configurationDefaults.ts index c777041..fe33928 100644 --- a/src/configurationDefaults.ts +++ b/src/configurationDefaults.ts @@ -7,10 +7,13 @@ import StrategyDefaults = generic.StrategyDefaults; export const configurationDefaults: StrategyDefaults = { areas: { undisclosed: { - aliases: [], area_id: "undisclosed", + floor_id: null, name: "Undisclosed", picture: null, + icon: "mdi:floor-plan", + labels: [], + aliases: [], hidden: false, } }, diff --git a/src/types/homeassistant/data/area_registry.ts b/src/types/homeassistant/data/area_registry.ts index 2e5d3c1..0d07e9a 100644 --- a/src/types/homeassistant/data/area_registry.ts +++ b/src/types/homeassistant/data/area_registry.ts @@ -2,13 +2,19 @@ * Area Entity. * * @property {string} area_id The id of the area. + * @property {string|null} floor_id The id of the area's floor. * @property {string} name Name of the area. * @property {string|null} picture URL to a picture that should be used instead of showing the domain icon. + * @property {string|null} icon Icon to show. + * @property {string[]} labels Labels allow grouping elements irrespective of their physical location or type. * @property {string[]} aliases Array of aliases of the area. */ export interface AreaRegistryEntry { area_id: string; + floor_id: string | null; name: string; picture: string | null; + icon: string | null; + labels: string[]; aliases: string[]; }