mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
Always show energy-sources-table in overview (#28315)
This commit is contained in:
@@ -8,14 +8,6 @@ import type { LovelaceStrategyConfig } from "../../../data/lovelace/config/strat
|
||||
import type { LovelaceSectionConfig } from "../../../data/lovelace/config/section";
|
||||
import { DEFAULT_ENERGY_COLLECTION_KEY } from "../ha-panel-energy";
|
||||
|
||||
const sourceHasCost = (source: Record<string, any>): boolean =>
|
||||
Boolean(
|
||||
source.stat_cost ||
|
||||
source.stat_compensation ||
|
||||
source.entity_energy_price ||
|
||||
source.number_energy_price
|
||||
);
|
||||
|
||||
@customElement("energy-overview-view-strategy")
|
||||
export class EnergyOverviewViewStrategy extends ReactiveElement {
|
||||
static async generate(
|
||||
@@ -68,13 +60,6 @@ export class EnergyOverviewViewStrategy extends ReactiveElement {
|
||||
(source.type === "battery" && source.stat_rate) ||
|
||||
(source.type === "grid" && source.power?.length)
|
||||
);
|
||||
const hasCost = prefs.energy_sources.some(
|
||||
(source) =>
|
||||
sourceHasCost(source) ||
|
||||
(source.type === "grid" &&
|
||||
(source.flow_from?.some(sourceHasCost) ||
|
||||
source.flow_to?.some(sourceHasCost)))
|
||||
);
|
||||
|
||||
const overviewSection: LovelaceSectionConfig = {
|
||||
type: "grid",
|
||||
@@ -95,7 +80,7 @@ export class EnergyOverviewViewStrategy extends ReactiveElement {
|
||||
}
|
||||
view.sections!.push(overviewSection);
|
||||
|
||||
if (hasCost) {
|
||||
if (prefs.energy_sources.length) {
|
||||
view.sections!.push({
|
||||
type: "grid",
|
||||
cards: [
|
||||
|
||||
Reference in New Issue
Block a user