Skip to content

Commit

Permalink
Use EnergyCardBaseConfig where appropriate (#20896)
Browse files Browse the repository at this point in the history
* Use EnergyCardBaseConfig where appropriate

* Update type key

* Rename class

* Run prettier
  • Loading branch information
TurnrDev authored Jun 21, 2024
1 parent 686424f commit eb0579d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand All @@ -39,7 +39,7 @@ class HuiEnergyGridGaugeCard
{
@property({ attribute: false }) public hass?: HomeAssistant;

@state() private _config?: EnergyGridGaugeCardConfig;
@state() private _config?: EnergyGridNeutralityGaugeCardConfig;

@state() private _data?: EnergyData;

Expand All @@ -59,7 +59,7 @@ class HuiEnergyGridGaugeCard
return 4;
}

public setConfig(config: EnergyGridGaugeCardConfig): void {
public setConfig(config: EnergyGridNeutralityGaugeCardConfig): void {
this._config = config;
}

Expand Down
43 changes: 16 additions & 27 deletions src/panels/lovelace/cards/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit eb0579d

Please sign in to comment.