diff --git a/cast/src/receiver/layout/hc-main.ts b/cast/src/receiver/layout/hc-main.ts index 341c4e0fe18d..7287b024667f 100644 --- a/cast/src/receiver/layout/hc-main.ts +++ b/cast/src/receiver/layout/hc-main.ts @@ -260,7 +260,7 @@ export class HcMain extends HassElement { { strategy: { type: "energy", - options: { show_date_selection: true }, + show_date_selection: true, }, }, ], diff --git a/src/data/lovelace.ts b/src/data/lovelace.ts index 3942d2763c1d..76a2e401e3e7 100644 --- a/src/data/lovelace.ts +++ b/src/data/lovelace.ts @@ -17,9 +17,9 @@ export interface LovelacePanelConfig { mode: "yaml" | "storage"; } -export type LovelaceStrategyConfig> = { +export type LovelaceStrategyConfig = { type: string; - options?: T; + [key: string]: any; }; export interface LovelaceConfig { diff --git a/src/panels/energy/strategies/energy-view-strategy.ts b/src/panels/energy/strategies/energy-view-strategy.ts index 1f2d539fac40..ff10a985f9fc 100644 --- a/src/panels/energy/strategies/energy-view-strategy.ts +++ b/src/panels/energy/strategies/energy-view-strategy.ts @@ -24,14 +24,14 @@ const setupWizard = async (): Promise => { }; }; -export type EnergeryViewStrategyOptions = { +export interface EnergeryViewStrategyConfig extends LovelaceStrategyConfig { show_date_selection?: boolean; -}; +} @customElement("energy-view-strategy") export class EnergyViewStrategy extends ReactiveElement { static async generate( - config: LovelaceStrategyConfig, + config: EnergeryViewStrategyConfig, hass: HomeAssistant, params: LovelaceStrategyParams ): Promise { @@ -67,7 +67,7 @@ export class EnergyViewStrategy extends ReactiveElement { (source) => source.type === "water" ); - if (params.narrow || config.options?.show_date_selection) { + if (params.narrow || config.show_date_selection) { view.cards!.push({ type: "energy-date-selection", collection_key: "energy_dashboard", diff --git a/src/panels/lovelace/strategies/get-strategy.ts b/src/panels/lovelace/strategies/get-strategy.ts index df697f5bc250..4f30b7c17592 100644 --- a/src/panels/lovelace/strategies/get-strategy.ts +++ b/src/panels/lovelace/strategies/get-strategy.ts @@ -108,7 +108,14 @@ const generateStrategy = async ( } } - return await strategy.generate(strategyConfig, hass, params); + const config = { + ...strategyConfig, + ...strategyConfig.options, + }; + + delete config.options; + + return await strategy.generate(config, hass, params); } catch (err: any) { if (err.message !== "timeout") { // eslint-disable-next-line