From bc6649dff8a478f71b2052b01bb4ec1df3220418 Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Mon, 7 Mar 2022 15:03:41 +0100 Subject: [PATCH] Dont' start femrentationstep before mqtt sensor has received a value --- cbpi/__init__.py | 2 +- cbpi/extension/FermentationStep/__init__.py | 13 +++++++++---- cbpi/extension/mqtt_sensor/__init__.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 733b151..c58b6d8 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.2.0.a15" +__version__ = "4.0.2.0.a16" diff --git a/cbpi/extension/FermentationStep/__init__.py b/cbpi/extension/FermentationStep/__init__.py index 442c84b..947be94 100644 --- a/cbpi/extension/FermentationStep/__init__.py +++ b/cbpi/extension/FermentationStep/__init__.py @@ -91,7 +91,6 @@ class FermenterTargetTempStep(CBPiFermentationStep): async def on_start(self): self.shutdown = False self.AutoMode = True if self.props.get("AutoMode","No") == "Yes" else False - self.starttemp= self.get_sensor_value(self.props.get("Sensor", None)).get("value") if self.fermenter is not None: self.fermenter.target_temp = int(self.props.get("Temp", 0)) if self.AutoMode == True: @@ -109,11 +108,14 @@ class FermenterTargetTempStep(CBPiFermentationStep): await self.push_update() async def run(self): + while self.get_sensor_value(self.props.get("Sensor", None)).get("value") > 900: + await asyncio.sleep(1) + self.starttemp= self.get_sensor_value(self.props.get("Sensor", None)).get("value") if self.fermenter.target_temp >= self.starttemp: logging.info("warmup") while self.running == True: sensor_value = self.get_sensor_value(self.props.get("Sensor", None)).get("value") - if sensor_value < 900 and sensor_value >= self.fermenter.target_temp and self.timer.is_running is not True: + if sensor_value >= self.fermenter.target_temp and self.timer.is_running is not True: self.timer.start() self.timer.is_running = True await asyncio.sleep(1) @@ -121,7 +123,7 @@ class FermenterTargetTempStep(CBPiFermentationStep): logging.info("Cooldown") while self.running == True: sensor_value = self.get_sensor_value(self.props.get("Sensor", None)).get("value") - if sensor_value < 900 and sensor_value <= self.fermenter.target_temp and self.timer.is_running is not True: + if sensor_value <= self.fermenter.target_temp and self.timer.is_running is not True: self.timer.start() self.timer.is_running = True await asyncio.sleep(1) @@ -201,7 +203,6 @@ class FermenterStep(CBPiFermentationStep): self.fermentationtime = self.endtime - time.time() self.AutoMode = True if self.props.get("AutoMode", "No") == "Yes" else False - self.starttemp= self.get_sensor_value(self.props.get("Sensor", None)).get("value") if self.fermenter is not None: self.fermenter.target_temp = int(self.props.get("Temp", 0)) if self.AutoMode == True: @@ -247,6 +248,10 @@ class FermenterStep(CBPiFermentationStep): self.timer.is_running == False async def run(self): + while self.get_sensor_value(self.props.get("Sensor", None)).get("value") > 900: + await asyncio.sleep(1) + self.starttemp= self.get_sensor_value(self.props.get("Sensor", None)).get("value") + if self.fermenter.target_temp >= self.starttemp: logging.info("warmup") while self.running == True: diff --git a/cbpi/extension/mqtt_sensor/__init__.py b/cbpi/extension/mqtt_sensor/__init__.py index abc4fae..e2d6e48 100644 --- a/cbpi/extension/mqtt_sensor/__init__.py +++ b/cbpi/extension/mqtt_sensor/__init__.py @@ -18,7 +18,7 @@ class MQTTSensor(CBPiSensor): if self.payload_text != None: self.payload_text = self.payload_text.split('.') self.mqtt_task = self.cbpi.satellite.subcribe(self.Topic, self.on_message) - self.value: int = 999 + self.value: float = 999 async def on_message(self, message): val = json.loads(message)