Dont' start femrentationstep before mqtt sensor has received a value

This commit is contained in:
avollkopf 2022-03-07 15:03:41 +01:00
parent ecbb2d404d
commit bc6649dff8
3 changed files with 11 additions and 6 deletions

View file

@ -1 +1 @@
__version__ = "4.0.2.0.a15" __version__ = "4.0.2.0.a16"

View file

@ -91,7 +91,6 @@ class FermenterTargetTempStep(CBPiFermentationStep):
async def on_start(self): async def on_start(self):
self.shutdown = False self.shutdown = False
self.AutoMode = True if self.props.get("AutoMode","No") == "Yes" else 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: if self.fermenter is not None:
self.fermenter.target_temp = int(self.props.get("Temp", 0)) self.fermenter.target_temp = int(self.props.get("Temp", 0))
if self.AutoMode == True: if self.AutoMode == True:
@ -109,11 +108,14 @@ class FermenterTargetTempStep(CBPiFermentationStep):
await self.push_update() await self.push_update()
async def run(self): 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: if self.fermenter.target_temp >= self.starttemp:
logging.info("warmup") logging.info("warmup")
while self.running == True: while self.running == True:
sensor_value = self.get_sensor_value(self.props.get("Sensor", None)).get("value") 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.start()
self.timer.is_running = True self.timer.is_running = True
await asyncio.sleep(1) await asyncio.sleep(1)
@ -121,7 +123,7 @@ class FermenterTargetTempStep(CBPiFermentationStep):
logging.info("Cooldown") logging.info("Cooldown")
while self.running == True: while self.running == True:
sensor_value = self.get_sensor_value(self.props.get("Sensor", None)).get("value") 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.start()
self.timer.is_running = True self.timer.is_running = True
await asyncio.sleep(1) await asyncio.sleep(1)
@ -201,7 +203,6 @@ class FermenterStep(CBPiFermentationStep):
self.fermentationtime = self.endtime - time.time() self.fermentationtime = self.endtime - time.time()
self.AutoMode = True if self.props.get("AutoMode", "No") == "Yes" else 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: if self.fermenter is not None:
self.fermenter.target_temp = int(self.props.get("Temp", 0)) self.fermenter.target_temp = int(self.props.get("Temp", 0))
if self.AutoMode == True: if self.AutoMode == True:
@ -247,6 +248,10 @@ class FermenterStep(CBPiFermentationStep):
self.timer.is_running == False self.timer.is_running == False
async def run(self): 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: if self.fermenter.target_temp >= self.starttemp:
logging.info("warmup") logging.info("warmup")
while self.running == True: while self.running == True:

View file

@ -18,7 +18,7 @@ class MQTTSensor(CBPiSensor):
if self.payload_text != None: if self.payload_text != None:
self.payload_text = self.payload_text.split('.') self.payload_text = self.payload_text.split('.')
self.mqtt_task = self.cbpi.satellite.subcribe(self.Topic, self.on_message) 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): async def on_message(self, message):
val = json.loads(message) val = json.loads(message)