From 4a5b67e3205fedb6d0cd17127e2bdf32a4d1819c Mon Sep 17 00:00:00 2001 From: Thomas Konrad Date: Mon, 9 Oct 2023 17:27:22 +0200 Subject: [PATCH] Add 'max devices' config to Energy Devices Graph (#17553) --- .../lovelace/cards/energy/hui-energy-devices-graph-card.ts | 2 ++ src/panels/lovelace/cards/types.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts b/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts index ea787919fffc..a06032701bc2 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-devices-graph-card.ts @@ -278,6 +278,8 @@ export class HuiEnergyDevicesGraphCard chartData.sort((a, b) => b.x - a.x); + chartData.length = this._config?.max_devices || chartData.length; + chartData.forEach((d: any) => { const color = getColorByIndex(d.idx); diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 7ddeef08a39d..d1aae334080a 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -153,6 +153,7 @@ export interface EnergyDevicesGraphCardConfig extends LovelaceCardConfig { type: "energy-devices-graph"; title?: string; collection_key?: string; + max_devices?: number; } export interface EnergySourcesTableCardConfig extends LovelaceCardConfig {