From d929e1c134cbeef56a0ba1a85eadbea27e11cf47 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 4 Aug 2021 00:16:08 +0200 Subject: [PATCH] Add support for statistics card to demo (#9703) --- demo/src/stubs/history.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/demo/src/stubs/history.ts b/demo/src/stubs/history.ts index f5000a70a3..342b6cc4f0 100644 --- a/demo/src/stubs/history.ts +++ b/demo/src/stubs/history.ts @@ -85,8 +85,8 @@ const generateMeanStatistics = ( statistic_id: id, start: currentDate.toISOString(), mean, - min: mean, - max: mean, + min: mean - Math.random() * maxDiff, + max: mean + Math.random() * maxDiff, last_reset: "1970-01-01T00:00:00+00:00", state: mean, sum: null, @@ -340,11 +340,12 @@ export const mockHistory = (mockHass: MockHomeAssistant) => { return results; } ); + mockHass.mockWS("history/list_statistic_ids", () => []); mockHass.mockWS( "history/statistics_during_period", ({ statistic_ids, start_time, end_time }, hass) => { const start = new Date(start_time); - const end = new Date(end_time); + const end = end_time ? new Date(end_time) : new Date(); const statistics: Record = {};