mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-27 03:37:31 +00:00
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:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user