From 959c33624d75c7e968fb73e6fec590bf729a9f0d Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Mon, 28 Feb 2022 18:15:23 +0100 Subject: [PATCH] one more fix on timer reset for fermentationstep --- cbpi/__init__.py | 2 +- cbpi/controller/fermentation_controller.py | 5 +++-- cbpi/extension/FermentationStep/__init__.py | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 2629370..7eed2ed 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.2.0.a7" +__version__ = "4.0.2.0.a8" diff --git a/cbpi/controller/fermentation_controller.py b/cbpi/controller/fermentation_controller.py index c3e5392..1e2b3c6 100644 --- a/cbpi/controller/fermentation_controller.py +++ b/cbpi/controller/fermentation_controller.py @@ -427,6 +427,7 @@ class FermentationController: if step is None: self.logger.info("No futher step to start") else: + step.instance.endtime = 0 await step.instance.start() logging.info("Starting step {}".format(step.name)) step.status = StepState.ACTIVE @@ -530,9 +531,9 @@ class FermentationController: for step in item.steps: self.logger.info("Stopping Step {} {}".format(step.name, step.id)) try: - await step.instance.stop() + await step.instance.reset() + await step.instance.stop() step.status = StepState.INITIAL - step.endtime = 0 except Exception as e: self.logger.error(e) self.save() diff --git a/cbpi/extension/FermentationStep/__init__.py b/cbpi/extension/FermentationStep/__init__.py index 8ecb695..f7bf317 100644 --- a/cbpi/extension/FermentationStep/__init__.py +++ b/cbpi/extension/FermentationStep/__init__.py @@ -229,6 +229,12 @@ class FermenterStep(CBPiFermentationStep): await self.push_update() async def reset(self): + await self.timer.stop() + timeD=int(self.props.get("TimerD", 0)) + timeH=int(self.props.get("TimerH", 0)) + timeM=int(self.props.get("TimerM", 0)) + self.fermentationtime=(timeM+(60*timeH)+(1440*timeD)) *60 + self.timer = Timer(self.fermentationtime ,on_update=self.on_timer_update, on_done=self.on_timer_done) self.endtime = 0 await self.update_endtime()