From 76b11a7247ebf5c0ec37d56675a31ed0423a9bc6 Mon Sep 17 00:00:00 2001 From: prash3r Date: Fri, 2 Sep 2022 18:17:08 +0200 Subject: [PATCH 1/2] =?UTF-8?q?imports=20the=20whirlpool=20hop=20addition?= =?UTF-8?q?=20kbh=20with=20timer=20previously=20the=20whirlpool=20step=20h?= =?UTF-8?q?as=20been=20ignored=20when=20importing=20from=20a=20kbh=20datab?= =?UTF-8?q?ase.=20on=20creation=20the=20whirlpoolstep=20would=20only=20be?= =?UTF-8?q?=20on=20a=20hardcoded=2015=20minute=20timer.=20I=20added=20the?= =?UTF-8?q?=20optional=20timer=20as=20argument=20to=20create=5FWhirlpool?= =?UTF-8?q?=5FCooldown().=20And=20made=20use=20of=20it=20for=20negative=20?= =?UTF-8?q?hops=20timer=20imported=20from=20KBH.=20For=20KBH=20databases?= =?UTF-8?q?=20this=20is=20valid=20because=20if=20the=20hops=20timer=20valu?= =?UTF-8?q?e=20is=20negative=20it=20can=20only=20be=20the=20whirlpool=20ti?= =?UTF-8?q?mer=20and=20the=20value=20is=20the=20time=20that=20is=20set=20f?= =?UTF-8?q?or=20the=20brewing=20device=20for=20getting=20from=20boil=20to?= =?UTF-8?q?=20below=2080=C2=B0C.=20I=20did=20only=20test=20the=20data=20an?= =?UTF-8?q?d=20not=20the=20functionality,=20but=20it=20sucessfully=20repla?= =?UTF-8?q?ces=20the=20hardcoded=20"15"=20timer=20with=20the=20value=20fro?= =?UTF-8?q?m=20the=20first=20whirlpool=20hop=20addition=20while=20getting?= =?UTF-8?q?=20rid=20of=20the=20sign.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cbpi/controller/upload_controller.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cbpi/controller/upload_controller.py b/cbpi/controller/upload_controller.py index f0a32c2..2379faf 100644 --- a/cbpi/controller/upload_controller.py +++ b/cbpi/controller/upload_controller.py @@ -193,8 +193,19 @@ class UploadController: pass # get the hop addition times - c.execute('SELECT Zeit FROM Hopfengaben WHERE Vorderwuerze <> 1 AND Vorderwuerze <> 5 AND SudID = ?', (Recipe_ID,)) + c.execute('SELECT Zeit FROM Hopfengaben WHERE Vorderwuerze <> 1 AND SudID = ?', (Recipe_ID,)) hops = c.fetchall() + whirlpool = [] + for hop in hops: + if hop[0] < 0: + whirlpool.append(hop) + for whirl in whirlpool: + hops.remove(whirl) + + print(whirlpool) + print(hops) + + # get the misc addition times c.execute('SELECT Zugabedauer FROM WeitereZutatenGaben WHERE Zeitpunkt = 1 AND SudID = ?', (Recipe_ID,)) @@ -307,7 +318,7 @@ class UploadController: await self.create_step(step_string) - await self.create_Whirlpool_Cooldown() + await self.create_Whirlpool_Cooldown(str(abs(whirlpool[0][0]))) # from kbh this value comes as negative but must be positive self.cbpi.notify('KBH Recipe created', name, NotificationType.INFO) @@ -946,13 +957,13 @@ class UploadController: alert="Yes" return alert - async def create_Whirlpool_Cooldown(self): + async def create_Whirlpool_Cooldown(self, time : str = "15"): # Add Waitstep as Whirlpool if self.cooldown != "WaiStep" and self.cooldown !="": step_string = { "name": "Whirlpool", "props": { "Kettle": self.boilid, - "Timer": "15" + "Timer": time }, "status_text": "", "status": "I", @@ -965,7 +976,7 @@ class UploadController: step_name = "CoolDown" cooldown_sensor = "" step_temp = "" - step_timer = "15" + step_timer = time if step_type == "CooldownStep": cooldown_sensor = self.cbpi.config.get("steps_cooldown_sensor", None) if cooldown_sensor is None or cooldown_sensor == '': From cfc876f2f4aefcd9e7d9e68eadcaaeca5f14458c Mon Sep 17 00:00:00 2001 From: prash3r Date: Wed, 14 Sep 2022 15:08:59 +0200 Subject: [PATCH 2/2] KBH import with and without whirlpool additions --- cbpi/controller/upload_controller.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cbpi/controller/upload_controller.py b/cbpi/controller/upload_controller.py index 2379faf..92aec4f 100644 --- a/cbpi/controller/upload_controller.py +++ b/cbpi/controller/upload_controller.py @@ -202,11 +202,6 @@ class UploadController: for whirl in whirlpool: hops.remove(whirl) - print(whirlpool) - print(hops) - - - # get the misc addition times c.execute('SELECT Zugabedauer FROM WeitereZutatenGaben WHERE Zeitpunkt = 1 AND SudID = ?', (Recipe_ID,)) miscs = c.fetchall() @@ -318,8 +313,11 @@ class UploadController: await self.create_step(step_string) - await self.create_Whirlpool_Cooldown(str(abs(whirlpool[0][0]))) # from kbh this value comes as negative but must be positive - + if not whirlpool: + await self.create_Whirlpool_Cooldown() + else : + await self.create_Whirlpool_Cooldown(str(abs(whirlpool[0][0]))) # from kbh this value comes as negative but must be positive + self.cbpi.notify('KBH Recipe created', name, NotificationType.INFO) except: