Merge pull request #70 from avollkopf/revert-68-hop_text

Revert "add hop name to BoilStep and UploadController"
This commit is contained in:
Alexander Vollkopf 2022-10-03 12:05:22 +02:00 committed by GitHub
commit 7021131967
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 102 deletions

View file

@ -193,7 +193,6 @@ class UploadController:
pass pass
# get the hop addition times # get the hop addition times
c.execute('SELECT Zeit FROM Hopfengaben WHERE Vorderwuerze <> 1 AND SudID = ?', (Recipe_ID,)) c.execute('SELECT Zeit FROM Hopfengaben WHERE Vorderwuerze <> 1 AND SudID = ?', (Recipe_ID,))
hops = c.fetchall() hops = c.fetchall()
whirlpool = [] whirlpool = []
@ -204,11 +203,11 @@ class UploadController:
hops.remove(whirl) hops.remove(whirl)
# get the misc addition times # get the misc addition times
c.execute('SELECT Zugabedauer, Name FROM WeitereZutatenGaben WHERE Zeitpunkt = 1 AND SudID = ?', (Recipe_ID,)) c.execute('SELECT Zugabedauer FROM WeitereZutatenGaben WHERE Zeitpunkt = 1 AND SudID = ?', (Recipe_ID,))
miscs = c.fetchall() miscs = c.fetchall()
try: try:
c.execute('SELECT Zeit, Name FROM Hopfengaben WHERE Vorderwuerze = 1 AND SudID = ?', (Recipe_ID,)) c.execute('SELECT Zeit FROM Hopfengaben WHERE Vorderwuerze = 1 AND SudID = ?', (Recipe_ID,))
FW_Hops = c.fetchall() FW_Hops = c.fetchall()
FirstWort = self.getFirstWort(FW_Hops,"kbh") FirstWort = self.getFirstWort(FW_Hops,"kbh")
except: except:
@ -298,21 +297,14 @@ class UploadController:
"Sensor": self.boilkettle.sensor, "Sensor": self.boilkettle.sensor,
"Temp": int(self.BoilTemp), "Temp": int(self.BoilTemp),
"Timer": BoilTime, "Timer": BoilTime,
"First_Wort": FirstWort[0], "First_Wort": FirstWort,
"First_Wort_text": FirstWort[1],
"LidAlert": "Yes", "LidAlert": "Yes",
"Hop_1": Hops[0][0], "Hop_1": Hops[0],
"Hop_1_text": Hops[0][1], "Hop_2": Hops[1],
"Hop_2": Hops[1][0], "Hop_3": Hops[2],
"Hop_2_text": Hops[1][1], "Hop_4": Hops[3],
"Hop_3": Hops[2][0], "Hop_5": Hops[4],
"Hop_3_text": Hops[2][1], "Hop_6": Hops[5]
"Hop_4": Hops[3][0],
"Hop_4_text": Hops[3][1],
"Hop_5": Hops[4][0],
"Hop_5_text": Hops[4][1],
"Hop_6": Hops[5][0],
"Hop_6_text": Hops[5][1]
}, },
"status_text": "", "status_text": "",
"status": "I", "status": "I",
@ -374,7 +366,7 @@ class UploadController:
elif e["Hopfen_{}_Kochzeit".format(idx)] == "Whirlpool": elif e["Hopfen_{}_Kochzeit".format(idx)] == "Whirlpool":
alert = float(1) alert = float(1)
else: else:
self.cbpi.notify("No Number at Hoptime", "Please change json-File at Hopfen_{}_Kochzeit".format(idx), NotificationType.ERROR) self.api.notify(headline="No Number at Hoptime", message="Please change json-File at Hopfen_{}_Kochzeit".format(idx), type="danger")
alert = float(1) alert = float(1)
hops.append({"name":hops_name,"time":alert}) hops.append({"name":hops_name,"time":alert})
@ -527,21 +519,14 @@ class UploadController:
"Sensor": sensor, "Sensor": sensor,
"Temp": step_temp, "Temp": step_temp,
"Timer": step_time, "Timer": step_time,
"First_Wort": FirstWort[0], "First_Wort": FirstWort,
"First_Wort_text": FirstWort[1],
"LidAlert": LidAlert, "LidAlert": LidAlert,
"Hop_1": Hops[0][0], "Hop_1": Hops[0],
"Hop_1_text": Hops[0][1], "Hop_2": Hops[1],
"Hop_2": Hops[1][0], "Hop_3": Hops[2],
"Hop_2_text": Hops[1][1], "Hop_4": Hops[3],
"Hop_3": Hops[2][0], "Hop_5": Hops[4],
"Hop_3_text": Hops[2][1], "Hop_6": Hops[5]
"Hop_4": Hops[3][0],
"Hop_4_text": Hops[3][1],
"Hop_5": Hops[4][0],
"Hop_5_text": Hops[4][1],
"Hop_6": Hops[5][0],
"Hop_6_text": Hops[5][1]
}, },
"status_text": "", "status_text": "",
"status": "I", "status": "I",
@ -680,21 +665,14 @@ class UploadController:
"Sensor": sensor, "Sensor": sensor,
"Temp": step_temp, "Temp": step_temp,
"Timer": step_time, "Timer": step_time,
"First_Wort": FirstWort[0], "First_Wort": FirstWort,
"First_Wort_text": FirstWort[1],
"LidAlert": LidAlert, "LidAlert": LidAlert,
"Hop_1": Hops[0][0], "Hop_1": Hops[0],
"Hop_1_text": Hops[0][1], "Hop_2": Hops[1],
"Hop_2": Hops[1][0], "Hop_3": Hops[2],
"Hop_2_text": Hops[1][1], "Hop_4": Hops[3],
"Hop_3": Hops[2][0], "Hop_5": Hops[4],
"Hop_3_text": Hops[2][1], "Hop_6": Hops[5]
"Hop_4": Hops[3][0],
"Hop_4_text": Hops[3][1],
"Hop_5": Hops[4][0],
"Hop_5_text": Hops[4][1],
"Hop_6": Hops[5][0],
"Hop_6_text": Hops[5][1]
}, },
"status_text": "", "status_text": "",
"status": "I", "status": "I",
@ -889,21 +867,14 @@ class UploadController:
"Sensor": sensor, "Sensor": sensor,
"Temp": step_temp, "Temp": step_temp,
"Timer": step_time, "Timer": step_time,
"First_Wort": FirstWort[0], "First_Wort": FirstWort,
"First_Wort_text": FirstWort[1],
"LidAlert": LidAlert, "LidAlert": LidAlert,
"Hop_1": Hops[0][0], "Hop_1": Hops[0],
"Hop_1_text": Hops[0][1], "Hop_2": Hops[1],
"Hop_2": Hops[1][0], "Hop_3": Hops[2],
"Hop_2_text": Hops[1][1], "Hop_4": Hops[3],
"Hop_3": Hops[2][0], "Hop_5": Hops[4],
"Hop_3_text": Hops[2][1], "Hop_6": Hops[5]
"Hop_4": Hops[3][0],
"Hop_4_text": Hops[3][1],
"Hop_5": Hops[4][0],
"Hop_5_text": Hops[4][1],
"Hop_6": Hops[5][0],
"Hop_6_text": Hops[5][1]
}, },
"status_text": "", "status_text": "",
"status": "I", "status": "I",
@ -926,50 +897,48 @@ class UploadController:
## Hops which are not used in the boil step should not cause alerts ## Hops which are not used in the boil step should not cause alerts
if use != 'Aroma' and use != 'Boil': if use != 'Aroma' and use != 'Boil':
continue continue
alerts.append([float(hop.find('TIME').text), hop.find('NAME').text]) alerts.append(float(hop.find('TIME').text))
elif recipe_type == "bf": elif recipe_type == "bf":
use = hop['use'] use = hop['use']
if use != 'Aroma' and use != 'Boil': if use != 'Aroma' and use != 'Boil':
continue continue
alerts.append([float(hop['time']), hop['name']]) ## TODO: Testing alerts.append(float(hop['time']))
elif recipe_type == "kbh": elif recipe_type == "kbh":
alerts.append([float(hop[0]), hop[1]]) alerts.append(float(hop[0]))
elif recipe_type == "json": elif recipe_type == "json":
alerts.append([float(hop['time']), hop['name']]) alerts.append(float(hop['time']))
## There might also be miscelaneous additions during boild time ## There might also be miscelaneous additions during boild time
if miscs is not None: if miscs is not None:
for misc in miscs: for misc in miscs:
if recipe_type == "xml": if recipe_type == "xml":
alerts.append([float(misc.find('TIME').text), misc.find('NAME').text]) alerts.append(float(misc.find('TIME').text))
elif recipe_type == "bf": elif recipe_type == "bf":
use = misc['use'] use = misc['use']
if use != 'Aroma' and use != 'Boil': if use != 'Aroma' and use != 'Boil':
continue continue
alerts.append([float(misc['time']), misc['name']]) ## TODO: Testing alerts.append(float(misc['time']))
elif recipe_type == "kbh": elif recipe_type == "kbh":
alerts.append([float(misc[0]), misc[1]]) alerts.append(float(misc[0]))
elif recipe_type == "json": elif recipe_type == "json":
alerts.append([float(misc['time']), misc['name']]) alerts.append(float(misc['time']))
## Dedupe and order the additions by their time ## Dedupe and order the additions by their time, to prevent multiple alerts at the same time
alerts = sorted(list(set(alerts)))
## CBP should have these additions in reverse ## CBP should have these additions in reverse
alerts = sorted(alerts, key=lambda x:x[0], reverse=True) alerts.reverse()
hop_alerts = [] hop_alerts = []
for i in range(0,6): for i in range(0,6):
try: try:
hop_alerts.append(alerts[i]) hop_alerts.append(str(int(alerts[i])))
except: except:
hop_alerts.append([None, None]) hop_alerts.append(None)
return hop_alerts return hop_alerts
def getFirstWort(self, hops, recipe_type): def getFirstWort(self, hops, recipe_type):
alert = "No" alert = "No"
names = []
if recipe_type == "kbh": if recipe_type == "kbh":
if len(hops) != 0: if len(hops) != 0:
alert = "Yes" alert = "Yes"
for hop in hops:
names.append(hop[1])
elif recipe_type == "xml": elif recipe_type == "xml":
for hop in hops: for hop in hops:
use = hop.find('USE').text use = hop.find('USE').text
@ -977,19 +946,14 @@ class UploadController:
if use != 'First Wort': if use != 'First Wort':
continue continue
alert = "Yes" alert = "Yes"
names.append(hop.find('NAME').text)
elif recipe_type == "bf": elif recipe_type == "bf":
for hop in hops: for hop in hops:
if hop['use'] == "First Wort": if hop['use'] == "First Wort":
alert="Yes" alert="Yes"
names.append(hop['name']) ## TODO: Testing
elif recipe_type == "json": elif recipe_type == "json":
if len(hops) != 0: for hop in hops:
alert = "Yes" alert="Yes"
for hop in hops: return alert
names.append(hop['name'])
return [alert, " and ".join(names)]
async def create_Whirlpool_Cooldown(self, time : str = "15"): async def create_Whirlpool_Cooldown(self, time : str = "15"):
# Add Waitstep as Whirlpool # Add Waitstep as Whirlpool

View file

@ -322,19 +322,12 @@ class ActorStep(CBPiStep):
Property.Select(label="LidAlert",options=["Yes","No"], description="Trigger Alert to remove lid if temp is close to boil"), Property.Select(label="LidAlert",options=["Yes","No"], description="Trigger Alert to remove lid if temp is close to boil"),
Property.Select(label="AutoMode",options=["Yes","No"], description="Switch Kettlelogic automatically on and off -> Yes"), Property.Select(label="AutoMode",options=["Yes","No"], description="Switch Kettlelogic automatically on and off -> Yes"),
Property.Select("First_Wort", options=["Yes","No"], description="First Wort Hop alert if set to Yes"), Property.Select("First_Wort", options=["Yes","No"], description="First Wort Hop alert if set to Yes"),
Property.Text("First_Wort_text", configurable = True, description="First Wort Hop alert text"),
Property.Number("Hop_1", configurable = True, description="First Hop alert (minutes before finish)"), Property.Number("Hop_1", configurable = True, description="First Hop alert (minutes before finish)"),
Property.Text("Hop_1_text", configurable = True, description="First Hop alert text"),
Property.Number("Hop_2", configurable=True, description="Second Hop alert (minutes before finish)"), Property.Number("Hop_2", configurable=True, description="Second Hop alert (minutes before finish)"),
Property.Text("Hop_2_text", configurable = True, description="Second Hop alert text"),
Property.Number("Hop_3", configurable=True, description="Third Hop alert (minutes before finish)"), Property.Number("Hop_3", configurable=True, description="Third Hop alert (minutes before finish)"),
Property.Text("Hop_3_text", configurable = True, description="Third Hop alert text"),
Property.Number("Hop_4", configurable=True, description="Fourth Hop alert (minutes before finish)"), Property.Number("Hop_4", configurable=True, description="Fourth Hop alert (minutes before finish)"),
Property.Text("Hop_4_text", configurable = True, description="Fourth Hop alert text"),
Property.Number("Hop_5", configurable=True, description="Fifth Hop alert (minutes before finish)"), Property.Number("Hop_5", configurable=True, description="Fifth Hop alert (minutes before finish)"),
Property.Text("Hop_5_text", configurable = True, description="Fifth Hop alert text"), Property.Number("Hop_6", configurable=True, description="Sixth Hop alert (minutes before finish)")])
Property.Number("Hop_6", configurable=True, description="Sixth Hop alert (minutes before finish)"),
Property.Text("Hop_6_text", configurable = True, description="Sixth Hop alert text")])
class BoilStep(CBPiStep): class BoilStep(CBPiStep):
@action("Start Timer", []) @action("Start Timer", [])
@ -374,7 +367,6 @@ class BoilStep(CBPiStep):
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.first_wort_hop_flag = False self.first_wort_hop_flag = False
self.first_wort_hop=self.props.get("First_Wort", "No") self.first_wort_hop=self.props.get("First_Wort", "No")
self.first_wort_hop_text=self.props.get("First_Wort_text", None)
self.hops_added=["","","","","",""] self.hops_added=["","","","","",""]
self.remaining_seconds = None self.remaining_seconds = None
@ -397,14 +389,11 @@ class BoilStep(CBPiStep):
await self.setAutoMode(True) await self.setAutoMode(True)
await self.push_update() await self.push_update()
async def check_hop_timer(self, number, value, text): async def check_hop_timer(self, number, value):
if value is not None and self.hops_added[number-1] is not True: if value is not None and self.hops_added[number-1] is not True:
if self.remaining_seconds != None and self.remaining_seconds <= (int(value) * 60 + 1): if self.remaining_seconds != None and self.remaining_seconds <= (int(value) * 60 + 1):
self.hops_added[number-1]= True self.hops_added[number-1]= True
if text is not None and text != "": self.cbpi.notify('Hop Alert', "Please add Hop %s" % number, NotificationType.INFO)
self.cbpi.notify('Hop Alert', "Please add %s (%s)" % (text, number), NotificationType.INFO)
else:
self.cbpi.notify('Hop Alert', "Please add Hop %s" % number, NotificationType.INFO)
async def on_stop(self): async def on_stop(self):
await self.timer.stop() await self.timer.stop()
@ -420,10 +409,7 @@ class BoilStep(CBPiStep):
async def run(self): async def run(self):
if self.first_wort_hop_flag == False and self.first_wort_hop == "Yes": if self.first_wort_hop_flag == False and self.first_wort_hop == "Yes":
self.first_wort_hop_flag = True self.first_wort_hop_flag = True
if self.first_wort_hop_text is not None and self.first_wort_hop_text != "": self.cbpi.notify('First Wort Hop Addition!', 'Please add hops for first wort', NotificationType.INFO)
self.cbpi.notify('First Wort Hop Addition!', 'Please add %s for first wort' % self.first_wort_hop_text, NotificationType.INFO)
else:
self.cbpi.notify('First Wort Hop Addition!', 'Please add hops for first wort', NotificationType.INFO)
while self.running == True: while self.running == True:
await asyncio.sleep(1) await asyncio.sleep(1)
@ -440,7 +426,7 @@ class BoilStep(CBPiStep):
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%H:%M")), NotificationType.INFO) self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%H:%M")), NotificationType.INFO)
else: else:
for x in range(1, 6): for x in range(1, 6):
await self.check_hop_timer(x, self.props.get("Hop_%s" % x, None), self.props.get("Hop_%s_text" % x, None)) await self.check_hop_timer(x, self.props.get("Hop_%s" % x, None))
return StepResult.DONE return StepResult.DONE