mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-24 12:49:19 +00:00
Add power graphs in energy view (#28010)
This commit is contained in:
@@ -46,12 +46,39 @@ export class EnergyElectricityViewStrategy extends ReactiveElement {
|
|||||||
const hasBattery = prefs.energy_sources.some(
|
const hasBattery = prefs.energy_sources.some(
|
||||||
(source) => source.type === "battery"
|
(source) => source.type === "battery"
|
||||||
);
|
);
|
||||||
|
const hasPowerSources = prefs.energy_sources.find(
|
||||||
|
(source) =>
|
||||||
|
(source.type === "solar" && source.stat_rate) ||
|
||||||
|
(source.type === "battery" && source.stat_rate) ||
|
||||||
|
(source.type === "grid" && source.power?.length)
|
||||||
|
);
|
||||||
|
const hasPowerDevices = prefs.device_consumption.find(
|
||||||
|
(device) => device.stat_rate
|
||||||
|
);
|
||||||
|
|
||||||
view.cards!.push({
|
view.cards!.push({
|
||||||
type: "energy-compare",
|
type: "energy-compare",
|
||||||
collection_key: "energy_dashboard",
|
collection_key: "energy_dashboard",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hasPowerSources) {
|
||||||
|
if (hasPowerDevices) {
|
||||||
|
view.cards!.push({
|
||||||
|
title: hass.localize("ui.panel.energy.cards.power_sankey_title"),
|
||||||
|
type: "power-sankey",
|
||||||
|
collection_key: collectionKey,
|
||||||
|
grid_options: {
|
||||||
|
columns: 24,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
view.cards!.push({
|
||||||
|
title: hass.localize("ui.panel.energy.cards.power_sources_graph_title"),
|
||||||
|
type: "power-sources-graph",
|
||||||
|
collection_key: collectionKey,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Only include if we have a grid or battery.
|
// Only include if we have a grid or battery.
|
||||||
if (hasGrid || hasBattery) {
|
if (hasGrid || hasBattery) {
|
||||||
view.cards!.push({
|
view.cards!.push({
|
||||||
|
|||||||
@@ -9470,7 +9470,8 @@
|
|||||||
"energy_devices_detail_graph_title": "Individual devices detail usage",
|
"energy_devices_detail_graph_title": "Individual devices detail usage",
|
||||||
"energy_sankey_title": "Energy flow",
|
"energy_sankey_title": "Energy flow",
|
||||||
"energy_top_consumers_title": "Top consumers",
|
"energy_top_consumers_title": "Top consumers",
|
||||||
"power_sankey_title": "Current power flow"
|
"power_sankey_title": "Current power flow",
|
||||||
|
"power_sources_graph_title": "Power sources"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"history": {
|
"history": {
|
||||||
|
|||||||
Reference in New Issue
Block a user