diff --git a/aqimon/read/mock.py b/aqimon/read/mock.py index 5c4f841..9ad818d 100644 --- a/aqimon/read/mock.py +++ b/aqimon/read/mock.py @@ -11,11 +11,12 @@ class MockReader: """Mock reader class.""" - def __init__(self, fake_sleep_secs=5, raise_error_odds=50): + def __init__(self, fake_sleep_secs=5, raise_error_odds=50, warm_up_secs=5): """Create a mock reader.""" self.state = ReaderState(ReaderStatus.IDLE, None) self.fake_sleep_secs = fake_sleep_secs self.raise_error_odds = raise_error_odds + self.warm_up_secs = warm_up_secs async def read(self) -> AqiRead: """Read from the 'device'. @@ -25,6 +26,8 @@ async def read(self) -> AqiRead: Also, randomly fails some percentage of the time. """ try: + self.state = ReaderState(ReaderStatus.WARM_UP, None) + await asyncio.sleep(self.warm_up_secs) self.state = ReaderState(ReaderStatus.READING, None) raise_error_roll = random.randint(0, 100) if raise_error_roll < self.raise_error_odds: diff --git a/aqimon/static/images/loading.gif b/aqimon/static/images/loading.gif index be8a5be..d5d42eb 100644 Binary files a/aqimon/static/images/loading.gif and b/aqimon/static/images/loading.gif differ diff --git a/aqimon/static/images/warmingup.gif b/aqimon/static/images/warmingup.gif new file mode 100644 index 0000000..8ac68d8 Binary files /dev/null and b/aqimon/static/images/warmingup.gif differ diff --git a/elm/src/DeviceStatus.elm b/elm/src/DeviceStatus.elm index 808e712..4dae794 100644 --- a/elm/src/DeviceStatus.elm +++ b/elm/src/DeviceStatus.elm @@ -61,7 +61,7 @@ deviceStatusImage deviceStatus = "/static/images/loading.gif" WarmingUp -> - "/static/images/loading.gif" + "/static/images/warmingup.gif" Idle -> "/static/images/idle.png"