mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Show statistics in history card on first load (#24554)
* Show statistics in history card on first load * unnecessary line
This commit is contained in:
parent
95a99c7857
commit
07c4296771
@ -57,6 +57,8 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
||||
|
||||
private _subscribed?: Promise<(() => Promise<void>) | undefined>;
|
||||
|
||||
private _stateHistory?: HistoryResult;
|
||||
|
||||
public getCardSize(): number {
|
||||
return this._config?.title ? 2 : 0 + 2 * (this._entityIds?.length || 1);
|
||||
}
|
||||
@ -123,7 +125,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
||||
return;
|
||||
}
|
||||
|
||||
const stateHistory = computeHistory(
|
||||
this._stateHistory = computeHistory(
|
||||
this.hass!,
|
||||
combinedHistory,
|
||||
this._entityIds,
|
||||
@ -132,11 +134,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
||||
this._config?.split_device_classes
|
||||
);
|
||||
|
||||
this._history = mergeHistoryResults(
|
||||
stateHistory,
|
||||
this._statisticsHistory,
|
||||
this._config?.split_device_classes
|
||||
);
|
||||
this._mergeHistory();
|
||||
},
|
||||
this._hoursToShow,
|
||||
this._entityIds
|
||||
@ -151,6 +149,16 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
||||
this._setRedrawTimer();
|
||||
}
|
||||
|
||||
private _mergeHistory() {
|
||||
if (this._stateHistory) {
|
||||
this._history = mergeHistoryResults(
|
||||
this._stateHistory,
|
||||
this._statisticsHistory,
|
||||
this._config?.split_device_classes
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async _fetchStatistics(sensorNumericDeviceClasses: string[]) {
|
||||
const now = new Date();
|
||||
const start = new Date();
|
||||
@ -173,6 +181,8 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
||||
sensorNumericDeviceClasses,
|
||||
this._config?.split_device_classes
|
||||
);
|
||||
|
||||
this._mergeHistory();
|
||||
}
|
||||
|
||||
private _redrawGraph() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user