add hop text

This commit is contained in:
lopelex 2022-09-28 16:56:14 +02:00
parent ac3c880523
commit 2bc5bbb183
2 changed files with 76 additions and 44 deletions

View file

@ -193,15 +193,15 @@ 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, Name FROM Hopfengaben WHERE Vorderwuerze <> 1 AND Vorderwuerze <> 5 AND SudID = ?', (Recipe_ID,))
hops = c.fetchall()
# get the misc addition times
c.execute('SELECT Zugabedauer FROM WeitereZutatenGaben WHERE Zeitpunkt = 1 AND SudID = ?', (Recipe_ID,))
c.execute('SELECT Zugabedauer, Name FROM WeitereZutatenGaben WHERE Zeitpunkt = 1 AND SudID = ?', (Recipe_ID,))
miscs = c.fetchall()
try:
c.execute('SELECT Zeit FROM Hopfengaben WHERE Vorderwuerze = 1 AND SudID = ?', (Recipe_ID,))
c.execute('SELECT Zeit, Name FROM Hopfengaben WHERE Vorderwuerze = 1 AND SudID = ?', (Recipe_ID,))
FW_Hops = c.fetchall()
FirstWort = self.getFirstWort(FW_Hops,"kbh")
except:
@ -293,12 +293,18 @@ class UploadController:
"Timer": BoilTime,
"First_Wort": FirstWort,
"LidAlert": "Yes",
"Hop_1": Hops[0],
"Hop_2": Hops[1],
"Hop_3": Hops[2],
"Hop_4": Hops[3],
"Hop_5": Hops[4],
"Hop_6": Hops[5]
"Hop_1": Hops[0][0],
"Hop_1_text": Hops[0][1],
"Hop_2": Hops[1][0],
"Hop_2_text": Hops[1][1],
"Hop_3": Hops[2][0],
"Hop_3_text": Hops[2][1],
"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": "I",
@ -512,12 +518,18 @@ class UploadController:
"Timer": step_time,
"First_Wort": FirstWort,
"LidAlert": LidAlert,
"Hop_1": Hops[0],
"Hop_2": Hops[1],
"Hop_3": Hops[2],
"Hop_4": Hops[3],
"Hop_5": Hops[4],
"Hop_6": Hops[5]
"Hop_1": Hops[0][0],
"Hop_1_text": Hops[0][1],
"Hop_2": Hops[1][0],
"Hop_2_text": Hops[1][1],
"Hop_3": Hops[2][0],
"Hop_3_text": Hops[2][1],
"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": "I",
@ -658,12 +670,18 @@ class UploadController:
"Timer": step_time,
"First_Wort": FirstWort,
"LidAlert": LidAlert,
"Hop_1": Hops[0],
"Hop_2": Hops[1],
"Hop_3": Hops[2],
"Hop_4": Hops[3],
"Hop_5": Hops[4],
"Hop_6": Hops[5]
"Hop_1": Hops[0][0],
"Hop_1_text": Hops[0][1],
"Hop_2": Hops[1][0],
"Hop_2_text": Hops[1][1],
"Hop_3": Hops[2][0],
"Hop_3_text": Hops[2][1],
"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": "I",
@ -860,12 +878,18 @@ class UploadController:
"Timer": step_time,
"First_Wort": FirstWort,
"LidAlert": LidAlert,
"Hop_1": Hops[0],
"Hop_2": Hops[1],
"Hop_3": Hops[2],
"Hop_4": Hops[3],
"Hop_5": Hops[4],
"Hop_6": Hops[5]
"Hop_1": Hops[0][0],
"Hop_1_text": Hops[0][1],
"Hop_2": Hops[1][0],
"Hop_2_text": Hops[1][1],
"Hop_3": Hops[2][0],
"Hop_3_text": Hops[2][1],
"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": "I",
@ -888,41 +912,40 @@ class UploadController:
## Hops which are not used in the boil step should not cause alerts
if use != 'Aroma' and use != 'Boil':
continue
alerts.append(float(hop.find('TIME').text))
alerts.append([float(hop.find('TIME').text), hop.find('NAME').text])
elif recipe_type == "bf":
use = hop['use']
if use != 'Aroma' and use != 'Boil':
continue
alerts.append(float(hop['time']))
alerts.append([float(hop['time']), hop['name']]) ## TODO: Testing
elif recipe_type == "kbh":
alerts.append(float(hop[0]))
alerts.append([float(hop[0]), hop[1]])
elif recipe_type == "json":
alerts.append(float(hop['time']))
alerts.append([float(hop['time']), hop['name']])
## There might also be miscelaneous additions during boild time
if miscs is not None:
for misc in miscs:
if recipe_type == "xml":
alerts.append(float(misc.find('TIME').text))
alerts.append([float(misc.find('TIME').text), misc.find('NAME').text])
elif recipe_type == "bf":
use = misc['use']
if use != 'Aroma' and use != 'Boil':
continue
alerts.append(float(misc['time']))
alerts.append([float(misc['time']), misc['name']]) ## TODO: Testing
elif recipe_type == "kbh":
alerts.append(float(misc[0]))
alerts.append([float(misc[0]), misc[1]])
elif recipe_type == "json":
alerts.append(float(misc['time']))
## Dedupe and order the additions by their time, to prevent multiple alerts at the same time
alerts = sorted(list(set(alerts)))
alerts.append([float(misc['time']), misc['name']])
## Dedupe and order the additions by their time, to prevent? multiple alerts at the same time
## CBP should have these additions in reverse
alerts.reverse()
alerts = sorted(alerts, key=lambda x:x[0], reverse=True)
hop_alerts = []
for i in range(0,6):
try:
hop_alerts.append(str(int(alerts[i])))
hop_alerts.append(alerts[i])
except:
hop_alerts.append(None)
hop_alerts.append([None, None])
return hop_alerts
def getFirstWort(self, hops, recipe_type):

View file

@ -323,11 +323,17 @@ class ActorStep(CBPiStep):
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.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.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.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.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_6", configurable=True, description="Sixth 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.Text("Hop_6_text", configurable = True, description="Sixth Hop alert text")])
class BoilStep(CBPiStep):
@action("Start Timer", [])
@ -389,11 +395,14 @@ class BoilStep(CBPiStep):
await self.setAutoMode(True)
await self.push_update()
async def check_hop_timer(self, number, value):
async def check_hop_timer(self, number, value, text):
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):
self.hops_added[number-1]= True
self.cbpi.notify('Hop Alert', "Please add Hop %s" % number, NotificationType.INFO)
if text is not None and text != "":
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):
await self.timer.stop()
@ -426,7 +435,7 @@ class BoilStep(CBPiStep):
self.cbpi.notify(self.name, 'Timer started. Estimated completion: {}'.format(estimated_completion_time.strftime("%H:%M")), NotificationType.INFO)
else:
for x in range(1, 6):
await self.check_hop_timer(x, self.props.get("Hop_%s" % x, None))
await self.check_hop_timer(x, self.props.get("Hop_%s" % x, None), self.props.get("Hop_%s_text" % x, None))
return StepResult.DONE