mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-15 07:25:54 +00:00
Fix hardcoded collection keys in energy dashboard (#29623)
Correct hardcoded collection keys Some elements in the energy overview strategy, and all in the energy view strategy were using hardcoded literals rather than the assigned collection key.
This commit is contained in:
@@ -40,6 +40,7 @@ import "../lovelace/views/hui-view";
|
||||
import "../lovelace/views/hui-view-container";
|
||||
|
||||
export const DEFAULT_ENERGY_COLLECTION_KEY = "energy_dashboard";
|
||||
export const DEFAULT_POWER_COLLECTION_KEY = "energy_dashboard_now";
|
||||
|
||||
const EMPTY_PREFERENCES: EnergyPreferences = {
|
||||
energy_sources: [],
|
||||
@@ -87,7 +88,7 @@ const POWER_VIEW = {
|
||||
path: "now",
|
||||
strategy: {
|
||||
type: "power",
|
||||
collection_key: "energy_dashboard_now",
|
||||
collection_key: DEFAULT_POWER_COLLECTION_KEY,
|
||||
},
|
||||
} as LovelaceViewConfig;
|
||||
|
||||
@@ -350,7 +351,7 @@ class PanelEnergy extends LitElement {
|
||||
|
||||
private _dumpCSV = async () => {
|
||||
const energyData = getEnergyDataCollection(this.hass, {
|
||||
key: "energy_dashboard",
|
||||
key: DEFAULT_ENERGY_COLLECTION_KEY,
|
||||
});
|
||||
|
||||
if (!energyData.prefs || !energyData.state.stats) {
|
||||
|
||||
@@ -119,7 +119,7 @@ export class EnergyOverviewViewStrategy extends ReactiveElement {
|
||||
"ui.panel.energy.cards.energy_usage_graph_title"
|
||||
),
|
||||
type: "energy-usage-graph",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
|
||||
view.cards!.push({
|
||||
type: "energy-compare",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
|
||||
// Only include if we have a grid or battery.
|
||||
@@ -63,7 +63,7 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
view.cards!.push({
|
||||
title: hass.localize("ui.panel.energy.cards.energy_usage_graph_title"),
|
||||
type: "energy-usage-graph",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
view.cards!.push({
|
||||
title: hass.localize("ui.panel.energy.cards.energy_solar_graph_title"),
|
||||
type: "energy-solar-graph",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
title: hass.localize("ui.panel.energy.cards.energy_distribution_title"),
|
||||
type: "energy-distribution",
|
||||
view_layout: { position: "sidebar" },
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
"ui.panel.energy.cards.energy_sources_table_title"
|
||||
),
|
||||
type: "energy-sources-table",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
types: ["grid", "solar", "battery"],
|
||||
});
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
view.cards!.push({
|
||||
type: "energy-grid-neutrality-gauge",
|
||||
view_layout: { position: "sidebar" },
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -112,14 +112,14 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
view.cards!.push({
|
||||
type: "energy-solar-consumed-gauge",
|
||||
view_layout: { position: "sidebar" },
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
}
|
||||
if (hasGrid) {
|
||||
view.cards!.push({
|
||||
type: "energy-self-sufficiency-gauge",
|
||||
view_layout: { position: "sidebar" },
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
view.cards!.push({
|
||||
type: "energy-carbon-consumed-gauge",
|
||||
view_layout: { position: "sidebar" },
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -140,19 +140,19 @@ export class EnergyViewStrategy extends ReactiveElement {
|
||||
"ui.panel.energy.cards.energy_devices_detail_graph_title"
|
||||
),
|
||||
type: "energy-devices-detail-graph",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
view.cards!.push({
|
||||
title: hass.localize(
|
||||
"ui.panel.energy.cards.energy_devices_graph_title"
|
||||
),
|
||||
type: "energy-devices-graph",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
});
|
||||
view.cards!.push({
|
||||
title: hass.localize("ui.panel.energy.cards.energy_sankey_title"),
|
||||
type: "energy-sankey",
|
||||
collection_key: "energy_dashboard",
|
||||
collection_key: collectionKey,
|
||||
group_by_floor: showFloorsNAreas,
|
||||
group_by_area: showFloorsNAreas,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user