Add proper type definition for energy device data items

Replaced `any` type with proper `EnergyDeviceDataItem` interface for better type safety while maintaining correct runtime behavior.

Addresses code review feedback.

Co-authored-by: MindFreeze <5219205+MindFreeze@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-24 09:53:06 +00:00
parent a2a5d68f3f
commit 95691a859b

View File

@@ -39,6 +39,16 @@ import { listenMediaQuery } from "../../../../common/dom/media_query";
import { getEnergyColor } from "./common/color";
import type { CustomLegendOption } from "../../../../components/chart/ha-chart-base";
interface EnergyDeviceDataItem {
id: string;
value: [number, string];
name: string;
itemStyle: {
color: string;
borderColor: string;
};
}
@customElement("hui-energy-devices-graph-card")
export class HuiEnergyDevicesGraphCard
extends SubscribeMixin(LitElement)
@@ -478,9 +488,9 @@ export class HuiEnergyDevicesGraphCard
}
const totalChart = pieChartData.reduce(
(acc: number, d) =>
this._hiddenStats.includes((d as any).id as string)
this._hiddenStats.includes((d as EnergyDeviceDataItem).id)
? acc
: acc + (d as any).value[0],
: acc + (d as EnergyDeviceDataItem).value[0],
0
);
datasets.push({