change interval if 5 min stats

This commit is contained in:
Bram Kragten 2022-09-28 15:03:01 +02:00
parent 71c43058ea
commit da38cbccf1
No known key found for this signature in database
GPG Key ID: FBE2DFDB363EF55B
1 changed files with 6 additions and 2 deletions

View File

@ -58,7 +58,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
clearInterval(this._interval);
this._interval = window.setInterval(
() => this._getStatistics(),
1000 * 60 * 60
this._intervalTimeout
);
}
@ -126,7 +126,7 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
clearInterval(this._interval);
this._interval = window.setInterval(
() => this._getStatistics(),
1000 * 60 * 60
this._intervalTimeout
);
}
}
@ -156,6 +156,10 @@ export class HuiStatisticsGraphCard extends LitElement implements LovelaceCard {
`;
}
private get _intervalTimeout(): number {
return (this._config?.period === "5minute" ? 5 : 60) * 1000 * 60;
}
private async _getStatistics(): Promise<void> {
const startDate = new Date();
startDate.setTime(