From f93cf3a3260a9318627bf22358e1026b79f60bbc Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Wed, 29 May 2024 11:50:44 +0100 Subject: [PATCH 1/4] Use EnergyCardBaseConfig where appropriate --- src/panels/lovelace/cards/types.ts | 39 ++++++++++-------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index d68e05a42f41..86993bf26240 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -118,85 +118,72 @@ 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 { +export interface EnergyGridGaugeCardConfig extends EnergyCardBaseConfig { type: "energy-grid-result-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 { From 7e79590ba14f7665d4dc002d96efbe7fbb8725c5 Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Wed, 29 May 2024 12:06:33 +0100 Subject: [PATCH 2/4] Update type key --- src/panels/lovelace/cards/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 86993bf26240..94918fbf6b77 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -177,7 +177,7 @@ export interface EnergySelfSufficiencyGaugeCardConfig } export interface EnergyGridGaugeCardConfig extends EnergyCardBaseConfig { - type: "energy-grid-result-gauge"; + type: "energy-grid-neutrality-gauge"; title?: string; } From b09d35ab74927cec1e0321daca058695144c7bc7 Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Thu, 20 Jun 2024 17:48:11 +0100 Subject: [PATCH 3/4] Rename class --- .../cards/energy/hui-energy-grid-neutrality-gauge-card.ts | 6 +++--- src/panels/lovelace/cards/types.ts | 2 +- 2 files changed, 4 insertions(+), 4 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 94918fbf6b77..f75bae27e576 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -176,7 +176,7 @@ export interface EnergySelfSufficiencyGaugeCardConfig title?: string; } -export interface EnergyGridGaugeCardConfig extends EnergyCardBaseConfig { +export interface EnergyGridNeutralityGaugeCardConfig extends EnergyCardBaseConfig { type: "energy-grid-neutrality-gauge"; title?: string; } From 32bffda8f51507b0e54eaf3e8b5d8f91d73cf895 Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Thu, 20 Jun 2024 18:00:50 +0100 Subject: [PATCH 4/4] Run prettier --- src/panels/lovelace/cards/types.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index f75bae27e576..91e8bc2dfca8 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -154,7 +154,8 @@ export interface EnergyDevicesGraphCardConfig extends EnergyCardBaseConfig { max_devices?: number; } -export interface EnergyDevicesDetailGraphCardConfig extends EnergyCardBaseConfig { +export interface EnergyDevicesDetailGraphCardConfig + extends EnergyCardBaseConfig { type: "energy-devices-detail-graph"; title?: string; max_devices?: number; @@ -176,7 +177,8 @@ export interface EnergySelfSufficiencyGaugeCardConfig title?: string; } -export interface EnergyGridNeutralityGaugeCardConfig extends EnergyCardBaseConfig { +export interface EnergyGridNeutralityGaugeCardConfig + extends EnergyCardBaseConfig { type: "energy-grid-neutrality-gauge"; title?: string; }