You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
7.3KB

  1. # -*- coding: utf-8 -*-
  2. import time
  3. from modules.core.props import Property, StepProperty
  4. from modules.core.step import StepBase
  5. from modules import cbpi
  6. @cbpi.step
  7. class MashStep(StepBase):
  8. '''
  9. Just put the decorator @cbpi.step on top of a method
  10. '''
  11. # Properties
  12. temp = Property.Number("Temperature", configurable=True, description="Target Temperature of Mash Step")
  13. kettle = StepProperty.Kettle("Kettle", description="Kettle in which the mashing takes place")
  14. timer = Property.Number("Timer in Minutes", configurable=True, description="Timer is started when the target temperature is reached")
  15. def init(self):
  16. '''
  17. Initialize Step. This method is called once at the beginning of the step
  18. :return:
  19. '''
  20. # set target tep
  21. self.set_target_temp(self.temp, self.kettle)
  22. @cbpi.action("Start Timer Now")
  23. def start(self):
  24. '''
  25. Custom Action which can be execute form the brewing dashboard.
  26. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface
  27. :return:
  28. '''
  29. if self.is_timer_finished() is None:
  30. self.start_timer(int(self.timer) * 60)
  31. def reset(self):
  32. self.stop_timer()
  33. self.set_target_temp(self.temp, self.kettle)
  34. def finish(self):
  35. self.set_target_temp(0, self.kettle)
  36. def execute(self):
  37. '''
  38. This method is execute in an interval
  39. :return:
  40. '''
  41. # Check if Target Temp is reached
  42. if self.get_kettle_temp(self.kettle) >= float(self.temp):
  43. # Check if Timer is Running
  44. if self.is_timer_finished() is None:
  45. self.start_timer(int(self.timer) * 60)
  46. # Check if timer finished and go to next step
  47. if self.is_timer_finished() == True:
  48. <<<<<<< HEAD
  49. self.notify("Mash Step Completed!", "Starting the next step", timeout=None)
  50. =======
  51. self.notify("Step Completed!", "Starting the next step", timeout=None)
  52. >>>>>>> 1c4e16e35839ec699a431a3840d7dfda9430c4cf
  53. self.next()
  54. @cbpi.step
  55. class MashInStep(StepBase):
  56. '''
  57. Just put the decorator @cbpi.step on top of a method
  58. '''
  59. # Properties
  60. temp = Property.Number("Temperature", configurable=True, description="Target Temperature of Mash Step")
  61. kettle = StepProperty.Kettle("Kettle", description="Kettle in which the mashing takes place")
  62. s = False
  63. @cbpi.action("Change Power")
  64. def change_power(self):
  65. self.actor_power(1, 50)
  66. def init(self):
  67. '''
  68. Initialize Step. This method is called once at the beginning of the step
  69. :return:
  70. '''
  71. # set target tep
  72. self.s = False
  73. self.set_target_temp(self.temp, self.kettle)
  74. def execute(self):
  75. '''
  76. This method is execute in an interval
  77. :return:
  78. '''
  79. # Check if Target Temp is reached
  80. if self.get_kettle_temp(self.kettle) >= float(self.temp) and self.s is False:
  81. self.s = True
  82. self.notify("Step Temp Reached!", "Please press the next button to continue", timeout=None)
  83. @cbpi.step
  84. class ChilStep(StepBase):
  85. timer = Property.Number("Timer in Minutes", configurable=True, default_value=0, description="Timer is started immediately")
  86. @cbpi.action("Stat Timer")
  87. def start(self):
  88. if self.is_timer_finished() is None:
  89. self.start_timer(int(self.timer) * 60)
  90. def reset(self):
  91. self.stop_timer()
  92. def finish(self):
  93. pass
  94. def execute(self):
  95. if self.is_timer_finished() is None:
  96. self.start_timer(int(self.timer) * 60)
  97. if self.is_timer_finished() == True:
  98. self.next()
  99. @cbpi.step
  100. class PumpStep(StepBase):
  101. pump = StepProperty.Actor("Pump", description="Pump actor gets toogled")
  102. timer = Property.Number("Timer in Minutes", configurable=True, default_value=0, description="Timer is started immediately")
  103. @cbpi.action("Stat Timer")
  104. def start(self):
  105. if self.is_timer_finished() is None:
  106. self.start_timer(int(self.timer) * 60)
  107. def reset(self):
  108. self.stop_timer()
  109. def finish(self):
  110. self.actor_off(int(self.pump))
  111. def init(self):
  112. self.actor_on(int(self.pump))
  113. def execute(self):
  114. if self.is_timer_finished() is None:
  115. self.start_timer(int(self.timer) * 60)
  116. if self.is_timer_finished() == True:
  117. self.next()
  118. @cbpi.step
  119. class BoilStep(StepBase):
  120. '''
  121. Just put the decorator @cbpi.step on top of a method
  122. '''
  123. # Properties
  124. temp = Property.Number("Temperature", configurable=True, default_value=100, description="Target temperature for boiling")
  125. kettle = StepProperty.Kettle("Kettle", description="Kettle in which the boiling step takes place")
  126. timer = Property.Number("Timer in Minutes", configurable=True, default_value=90, description="Timer is started when target temperature is reached")
  127. hop_1 = Property.Number("Hop 1 Addition", configurable=True, description="Fist Hop alert")
  128. hop_1_added = Property.Number("",default_value=None)
  129. hop_2 = Property.Number("Hop 2 Addition", configurable=True, description="Second Hop alert")
  130. hop_2_added = Property.Number("", default_value=None)
  131. hop_3 = Property.Number("Hop 3 Addition", configurable=True)
  132. hop_3_added = Property.Number("", default_value=None, description="Second Hop alert")
  133. def init(self):
  134. '''
  135. Initialize Step. This method is called once at the beginning of the step
  136. :return:
  137. '''
  138. # set target tep
  139. self.set_target_temp(self.temp, self.kettle)
  140. @cbpi.action("Start Timer Now")
  141. def start(self):
  142. '''
  143. Custom Action which can be execute form the brewing dashboard.
  144. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface
  145. :return:
  146. '''
  147. if self.is_timer_finished() is None:
  148. self.start_timer(int(self.timer) * 60)
  149. def reset(self):
  150. self.stop_timer()
  151. self.set_target_temp(self.temp, self.kettle)
  152. def finish(self):
  153. self.set_target_temp(0, self.kettle)
  154. def check_hop_timer(self, number, value):
  155. if self.__getattribute__("hop_%s_added" % number) is not True and time.time() > (
  156. self.timer_end - (int(self.timer) * 60 - int(value) * 60)):
  157. self.__setattr__("hop_%s_added" % number, True)
  158. self.notify("Hop Alert", "Please add Hop %s" % number, timeout=None)
  159. def execute(self):
  160. '''
  161. This method is execute in an interval
  162. :return:
  163. '''
  164. # Check if Target Temp is reached
  165. if self.get_kettle_temp(self.kettle) >= float(self.temp):
  166. self.notify("Boil Temp Reached!", "Starting the boil timer", timeout=None)
  167. # Check if Timer is Running
  168. if self.is_timer_finished() is None:
  169. self.start_timer(int(self.timer) * 60)
  170. else:
  171. self.check_hop_timer(1, self.hop_1)
  172. self.check_hop_timer(2, self.hop_2)
  173. self.check_hop_timer(3, self.hop_3)
  174. # Check if timer finished and go to next step
  175. if self.is_timer_finished() == True:
  176. self.notify("Boil Step Completed!", "Starting the next step", timeout=None)
  177. self.next()