diff --git a/src/components/chart/statistics-chart.ts b/src/components/chart/statistics-chart.ts index c2bcca5a4d..a82ed0d7c7 100644 --- a/src/components/chart/statistics-chart.ts +++ b/src/components/chart/statistics-chart.ts @@ -32,7 +32,7 @@ import { import type { HomeAssistant } from "../../types"; import "./ha-chart-base"; -export type ExtendedStatisticType = StatisticType | "state" | "change"; +export type ExtendedStatisticType = StatisticType | "change"; export const statTypeMap: Record = { mean: "mean", diff --git a/src/panels/lovelace/cards/hui-statistics-graph-card.ts b/src/panels/lovelace/cards/hui-statistics-graph-card.ts index 6e07eb5dcb..94caa11c5d 100644 --- a/src/panels/lovelace/cards/hui-statistics-graph-card.ts +++ b/src/panels/lovelace/cards/hui-statistics-graph-card.ts @@ -9,7 +9,10 @@ import { } from "lit"; import { customElement, property, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; -import "../../../components/chart/statistics-chart"; +import { + ExtendedStatisticType, + statTypeMap, +} from "../../../components/chart/statistics-chart"; import "../../../components/ha-card"; import { fetchStatistics, @@ -17,7 +20,6 @@ import { getStatisticMetadata, Statistics, StatisticsMetaData, - StatisticsTypes, } from "../../../data/recorder"; import { HomeAssistant } from "../../../types"; import { findEntities } from "../common/find-entities"; @@ -70,7 +72,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard { private _interval?: number; - private _statTypes?: StatisticsTypes; + private _statTypes?: Array; public disconnectedCallback() { super.disconnectedCallback(); @@ -249,7 +251,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard { this._entities, this._config!.period, unitconfig, - this._statTypes + this._statTypes?.map((stat_type) => statTypeMap[stat_type]) ); } catch (err) { this._statistics = undefined; diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 0e3bea773d..5ab627b466 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -1,4 +1,4 @@ -import { Statistic, StatisticType } from "../../../data/recorder"; +import { Statistic } from "../../../data/recorder"; import { ActionConfig, LovelaceCardConfig } from "../../../data/lovelace"; import { FullCalendarView, TranslationDict } from "../../../types"; import { Condition } from "../common/validate-condition"; @@ -10,6 +10,7 @@ import { LovelaceRowConfig, } from "../entity-rows/types"; import { LovelaceHeaderFooterConfig } from "../header-footer/types"; +import { ExtendedStatisticType } from "../../../components/chart/statistics-chart"; import { HaDurationData } from "../../../components/ha-duration-input"; import { LovelaceTileFeatureConfig } from "../tile-features/types"; @@ -309,7 +310,7 @@ export interface StatisticsGraphCardConfig extends LovelaceCardConfig { unit?: string; days_to_show?: number; period?: "5minute" | "hour" | "day" | "month"; - stat_types?: StatisticType | StatisticType[]; + stat_types?: ExtendedStatisticType | ExtendedStatisticType[]; chart_type?: "line" | "bar"; }