Skip to content

Commit

Permalink
Merge pull request Manuel83#105 from swimIan/patch2
Browse files Browse the repository at this point in the history
Updates the boilstep and beerxml recipe import
  • Loading branch information
Manuel83 authored Oct 13, 2017
2 parents 0339564 + b56c10a commit b279dcf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
30 changes: 21 additions & 9 deletions modules/base_plugins/brew_steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,18 @@ class BoilStep(StepBase):
temp = Property.Number("Temperature", configurable=True, default_value=100, description="Target temperature for boiling")
kettle = StepProperty.Kettle("Kettle", description="Kettle in which the boiling step takes place")
timer = Property.Number("Timer in Minutes", configurable=True, default_value=90, description="Timer is started when target temperature is reached")
hop_1 = Property.Number("Hop 1 Addition", configurable=True, description="Fist Hop alert")
hop_1 = Property.Number("Hop 1 Addition", configurable=True, description="First Hop alert")
hop_1_added = Property.Number("",default_value=None)
hop_2 = Property.Number("Hop 2 Addition", configurable=True, description="Second Hop alert")
hop_2_added = Property.Number("", default_value=None)
hop_3 = Property.Number("Hop 3 Addition", configurable=True)
hop_3_added = Property.Number("", default_value=None, description="Third Hop alert")
hop_4 = Property.Number("Hop 4 Addition", configurable=True)
hop_4_added = Property.Number("", default_value=None, description="Fourth Hop alert")
hop_5 = Property.Number("Hop 5 Addition", configurable=True)
hop_5_added = Property.Number("", default_value=None, description="Fives Hop alert")
hop_3 = Property.Number("Hop 3 Addition", configurable=True, description="Third Hop alert")
hop_3_added = Property.Number("", default_value=None)
hop_4 = Property.Number("Hop 4 Addition", configurable=True, description="Fourth Hop alert")
hop_4_added = Property.Number("", default_value=None)
hop_5 = Property.Number("Hop 5 Addition", configurable=True, description="Fifth Hop alert")
hop_5_added = Property.Number("", default_value=None)
fining = Property.Number("Fining Addition", configurable=True, default_value=15)
fining_added = Property.Number("",default_value=None, description="Fining Agent Alert")

def init(self):
'''
Expand Down Expand Up @@ -202,11 +204,18 @@ def finish(self):

def check_hop_timer(self, number, value):

if self.__getattribute__("hop_%s_added" % number) is not True and time.time() > (
self.timer_end - (int(self.timer) * 60 - int(value) * 60)):
if self.__getattribute__("hop_%s_added" % number) is not True and (int(value) * 60) == (
self.timer_end - int(time.time())):
self.__setattr__("hop_%s_added" % number, True)
self.notify("Hop Alert", "Please add Hop %s" % number, timeout=None)

def check_fining_timer(self, value):

if self.__getattribute__("fining_added") is not True and (int(value) * 60) == (
self.timer_end - int(time.time())):
self.__setattr__("fining_added", True)
self.notify("Fining Alert", "Please add fining agent", timeout=None)

def execute(self):
'''
This method is execute in an interval
Expand All @@ -216,13 +225,16 @@ def execute(self):
if self.get_kettle_temp(self.kettle) >= float(self.temp):
# Check if Timer is Running
if self.is_timer_finished() is None:
self.notify("Boil Temp Reached", "Starting the boil timer")
self.start_timer(int(self.timer) * 60)
else:
self.check_hop_timer(1, self.hop_1)
self.check_hop_timer(2, self.hop_2)
self.check_hop_timer(3, self.hop_3)
self.check_hop_timer(4, self.hop_4)
self.check_hop_timer(5, self.hop_5)
self.check_fining_timer(self.fining)

# Check if timer finished and go to next step
if self.is_timer_finished() == True:
self.notify("Boil Step Completed!", "Starting the next step", timeout=None)
Expand Down
14 changes: 13 additions & 1 deletion modules/recipe_import/beerxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def load(self, id):
name = self.getRecipeName(id)
self.api.set_config_parameter("brew_name", name)
boil_time = self.getBoilTime(id)
infuse = self.getMashinTemp(id)
mashinstep_type = cbpi.get_config_parameter("step_mashin", "MashInStep")
mashstep_type = cbpi.get_config_parameter("step_mash", "MashStep")
mash_kettle = cbpi.get_config_parameter("step_mash_kettle", None)

Expand All @@ -64,11 +66,13 @@ def load(self, id):

try:

## Add Mashin step
Step.insert(**{"name": "MashIn", "type": mashinstep_type, "config": {"kettle": mash_kettle, "temp": infuse}})
for row in steps:
Step.insert(**{"name": row.get("name"), "type": mashstep_type, "config": {"kettle": mash_kettle, "temp": float(row.get("temp")), "timer": row.get("timer")}})
Step.insert(**{"name": "ChilStep", "type": "ChilStep", "config": {"timer": 15}})
## Add cooking step
Step.insert(**{"name": "Boil", "type": boilstep_type, "config": {"kettle": boil_kettle, "temp": boil_temp, "timer": boil_time}})
Step.insert(**{"name": "ChilStep", "type": "ChilStep", "config": {"timer": 15}})
## Add Whirlpool step
Step.insert(**{"name": "Whirlpool", "type": "ChilStep", "config": {"timer": 15}})
self.api.emit("UPDATE_ALL_STEPS", Step.get_all())
Expand All @@ -87,6 +91,14 @@ def getBoilTime(self, id):
e = xml.etree.ElementTree.parse(self.BEER_XML_FILE).getroot()
return float(e.find('./RECIPE[%s]/BOIL_TIME' % (str(id))).text)

def getMashinTemp(self, id):
e = xml.etree.ElementTree.parse(self.BEER_XML_FILE).getroot()
tempstr = e.find('./RECIPE[%s]/MASH/MASH_STEPS/MASH_STEP/INFUSE_TEMP' % (str(id))).text
val = tempstr[:-1]
infuse = float(val.rstrip())

return infuse

def getSteps(self, id):


Expand Down

0 comments on commit b279dcf

Please sign in to comment.