Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/mushroom-strategy.ts
Comment thread
DigiLive marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,39 @@ class MushroomStrategy extends HTMLTemplateElement {
logMessage(lvlError, 'Error while handling persistent notifications for Mushroom Strategy', e);
}
}
}

customElements.define('ll-strategy-mushroom-strategy', MushroomStrategy);
/**
* Returns suggestions for creating a new dashboard with this strategy.
*
* @returns An object containing the title and icon for the dashboard creation suggestion.
*
* @remarks
* This method is used by Home Assistant to display a suggestion when the user opts to create a new dashboard.
*/
static getCreateSuggestions() {
return {
title: 'Mushroom Dashboard',
icon: 'mdi:mushroom',
};
}
}

const STRATEGY_VERSION = 'v3.1.0';

console.info(
'%c Mushroom Strategy %c '.concat(STRATEGY_VERSION, ' '),
'color: white; background: coral; font-weight: 700;',
'color: coral; background: white; font-weight: 700;'
);

customElements.define('ll-strategy-mushroom-strategy', MushroomStrategy);

// Register the strategy as a custom HASS dashboard.
window.customStrategies = window.customStrategies || [];
window.customStrategies.push({
type: 'mushroom-strategy',
strategyType: 'dashboard',
name: `Mushroom Dashboard Strategy ${STRATEGY_VERSION}`,
description: `A strategy to automatically generate a dashboard using mushroom cards.`,
documentationURL: `https://digilive.github.io/mushroom-strategy/${STRATEGY_VERSION}/`,
});
Comment thread
DigiLive marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Represents an entry in the custom Lovelace strategy registry in Home Assistant.
*
* @property {string} type - The unique strategy type identifier.
* @property {string} [name] - The display name of the strategy.
* @property {string} [description] - The description of the strategy.
* @property {string} [documentationURL] - The URL to the strategy documentation.
* @property {'dashboard'} strategyType - The strategy type.
*/
export interface CustomStrategyEntry {
type: string;
name?: string;
description?: string;
documentationURL?: string;
strategyType: 'dashboard';
}

declare global {
//noinspection JSUnusedGlobalSymbols This extends global Window and is used in mushroom-strategy.ts
/**
* Represents the browser window object for custom Lovelace strategy registration.
*
* @property {CustomStrategyEntry[]} [customStrategies] - The registered custom Lovelace strategies.
*/
interface Window {
customStrategies?: CustomStrategyEntry[];
}
}