mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-29 04:37:22 +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 { getEnergyColor } from "./common/color";
|
||||||
import type { CustomLegendOption } from "../../../../components/chart/ha-chart-base";
|
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")
|
@customElement("hui-energy-devices-graph-card")
|
||||||
export class HuiEnergyDevicesGraphCard
|
export class HuiEnergyDevicesGraphCard
|
||||||
extends SubscribeMixin(LitElement)
|
extends SubscribeMixin(LitElement)
|
||||||
@@ -478,9 +488,9 @@ export class HuiEnergyDevicesGraphCard
|
|||||||
}
|
}
|
||||||
const totalChart = pieChartData.reduce(
|
const totalChart = pieChartData.reduce(
|
||||||
(acc: number, d) =>
|
(acc: number, d) =>
|
||||||
this._hiddenStats.includes((d as any).id as string)
|
this._hiddenStats.includes((d as EnergyDeviceDataItem).id)
|
||||||
? acc
|
? acc
|
||||||
: acc + (d as any).value[0],
|
: acc + (d as EnergyDeviceDataItem).value[0],
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
datasets.push({
|
datasets.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user