forked from DigiLive/mushroom-strategy
Add auto import of area icons in home view (#158)
* Changed the default icon for an area. * Add auto import of area icons in home view (Closes #147). The default icon is overwritten at the constructor, if a user-defined icon is set in hass. --------- Co-authored-by: DigiLive <github@digilive.nl>
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
},
|
||||
|
@ -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[];
|
||||
}
|
||||
|
Reference in New Issue
Block a user