mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26: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 _subscribed?: Promise<(() => Promise<void>) | undefined>;
|
||||||
|
|
||||||
|
private _stateHistory?: HistoryResult;
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
return this._config?.title ? 2 : 0 + 2 * (this._entityIds?.length || 1);
|
return this._config?.title ? 2 : 0 + 2 * (this._entityIds?.length || 1);
|
||||||
}
|
}
|
||||||
@ -123,7 +125,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stateHistory = computeHistory(
|
this._stateHistory = computeHistory(
|
||||||
this.hass!,
|
this.hass!,
|
||||||
combinedHistory,
|
combinedHistory,
|
||||||
this._entityIds,
|
this._entityIds,
|
||||||
@ -132,11 +134,7 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this._config?.split_device_classes
|
this._config?.split_device_classes
|
||||||
);
|
);
|
||||||
|
|
||||||
this._history = mergeHistoryResults(
|
this._mergeHistory();
|
||||||
stateHistory,
|
|
||||||
this._statisticsHistory,
|
|
||||||
this._config?.split_device_classes
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
this._hoursToShow,
|
this._hoursToShow,
|
||||||
this._entityIds
|
this._entityIds
|
||||||
@ -151,6 +149,16 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
this._setRedrawTimer();
|
this._setRedrawTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _mergeHistory() {
|
||||||
|
if (this._stateHistory) {
|
||||||
|
this._history = mergeHistoryResults(
|
||||||
|
this._stateHistory,
|
||||||
|
this._statisticsHistory,
|
||||||
|
this._config?.split_device_classes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async _fetchStatistics(sensorNumericDeviceClasses: string[]) {
|
private async _fetchStatistics(sensorNumericDeviceClasses: string[]) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
@ -173,6 +181,8 @@ export class HuiHistoryGraphCard extends LitElement implements LovelaceCard {
|
|||||||
sensorNumericDeviceClasses,
|
sensorNumericDeviceClasses,
|
||||||
this._config?.split_device_classes
|
this._config?.split_device_classes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._mergeHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _redrawGraph() {
|
private _redrawGraph() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user