From eb0579ddc5a593b7da5cbf1a9edda74217448abe Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Fri, 21 Jun 2024 10:11:41 +0100 Subject: [PATCH] Use EnergyCardBaseConfig where appropriate (#20896) * Use EnergyCardBaseConfig where appropriate * Update type key * Rename class * Run prettier --- .../hui-energy-grid-neutrality-gauge-card.ts | 6 +-- src/panels/lovelace/cards/types.ts | 43 +++++++------------ 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts b/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts index 558762ca15b8..fbed586357c5 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-grid-neutrality-gauge-card.ts @@ -24,7 +24,7 @@ import { calculateStatisticsSumGrowth } from "../../../../data/recorder"; import { SubscribeMixin } from "../../../../mixins/subscribe-mixin"; import type { HomeAssistant } from "../../../../types"; import type { LovelaceCard } from "../../types"; -import type { EnergyGridGaugeCardConfig } from "../types"; +import type { EnergyGridNeutralityGaugeCardConfig } from "../types"; import { hasConfigChanged } from "../../common/has-changed"; const LEVELS: LevelDefinition[] = [ @@ -39,7 +39,7 @@ class HuiEnergyGridGaugeCard { @property({ attribute: false }) public hass?: HomeAssistant; - @state() private _config?: EnergyGridGaugeCardConfig; + @state() private _config?: EnergyGridNeutralityGaugeCardConfig; @state() private _data?: EnergyData; @@ -59,7 +59,7 @@ class HuiEnergyGridGaugeCard return 4; } - public setConfig(config: EnergyGridGaugeCardConfig): void { + public setConfig(config: EnergyGridNeutralityGaugeCardConfig): void { this._config = config; } diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index d68e05a42f41..91e8bc2dfca8 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -118,85 +118,74 @@ export interface EnergyCardBaseConfig extends LovelaceCardConfig { collection_key?: string; } -export interface EnergySummaryCardConfig extends LovelaceCardConfig { +export interface EnergySummaryCardConfig extends EnergyCardBaseConfig { type: "energy-summary"; title?: string; - collection_key?: string; } -export interface EnergyDistributionCardConfig extends LovelaceCardConfig { +export interface EnergyDistributionCardConfig extends EnergyCardBaseConfig { type: "energy-distribution"; title?: string; link_dashboard?: boolean; - collection_key?: string; } -export interface EnergyUsageGraphCardConfig extends LovelaceCardConfig { +export interface EnergyUsageGraphCardConfig extends EnergyCardBaseConfig { type: "energy-usage-graph"; title?: string; - collection_key?: string; } -export interface EnergySolarGraphCardConfig extends LovelaceCardConfig { +export interface EnergySolarGraphCardConfig extends EnergyCardBaseConfig { type: "energy-solar-graph"; title?: string; - collection_key?: string; } -export interface EnergyGasGraphCardConfig extends LovelaceCardConfig { +export interface EnergyGasGraphCardConfig extends EnergyCardBaseConfig { type: "energy-gas-graph"; title?: string; - collection_key?: string; } -export interface EnergyWaterGraphCardConfig extends LovelaceCardConfig { +export interface EnergyWaterGraphCardConfig extends EnergyCardBaseConfig { type: "energy-water-graph"; title?: string; - collection_key?: string; } -export interface EnergyDevicesGraphCardConfig extends LovelaceCardConfig { +export interface EnergyDevicesGraphCardConfig extends EnergyCardBaseConfig { type: "energy-devices-graph"; title?: string; - collection_key?: string; max_devices?: number; } -export interface EnergyDevicesDetailGraphCardConfig extends LovelaceCardConfig { +export interface EnergyDevicesDetailGraphCardConfig + extends EnergyCardBaseConfig { type: "energy-devices-detail-graph"; title?: string; - collection_key?: string; max_devices?: number; } -export interface EnergySourcesTableCardConfig extends LovelaceCardConfig { +export interface EnergySourcesTableCardConfig extends EnergyCardBaseConfig { type: "energy-sources-table"; title?: string; - collection_key?: string; } -export interface EnergySolarGaugeCardConfig extends LovelaceCardConfig { +export interface EnergySolarGaugeCardConfig extends EnergyCardBaseConfig { type: "energy-solar-consumed-gauge"; title?: string; - collection_key?: string; } export interface EnergySelfSufficiencyGaugeCardConfig - extends LovelaceCardConfig { + extends EnergyCardBaseConfig { type: "energy-self-sufficiency-gauge"; title?: string; - collection_key?: string; } -export interface EnergyGridGaugeCardConfig extends LovelaceCardConfig { - type: "energy-grid-result-gauge"; +export interface EnergyGridNeutralityGaugeCardConfig + extends EnergyCardBaseConfig { + type: "energy-grid-neutrality-gauge"; title?: string; - collection_key?: string; } -export interface EnergyCarbonGaugeCardConfig extends LovelaceCardConfig { +export interface EnergyCarbonGaugeCardConfig extends EnergyCardBaseConfig { type: "energy-carbon-consumed-gauge"; title?: string; - collection_key?: string; } export interface EntityFilterCardConfig extends LovelaceCardConfig {