您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

241 行
8.0KB

  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. self.notify("Mash Step Completed!", "Starting the next step", timeout=None)
  49. self.next()
  50. @cbpi.step
  51. class MashInStep(StepBase):
  52. '''
  53. Just put the decorator @cbpi.step on top of a method
  54. '''
  55. # Properties
  56. temp = Property.Number("Temperature", configurable=True, description="Target Temperature of Mash Step")
  57. kettle = StepProperty.Kettle("Kettle", description="Kettle in which the mashing takes place")
  58. s = False
  59. @cbpi.action("Change Power")
  60. def change_power(self):
  61. self.actor_power(1, 50)
  62. def init(self):
  63. '''
  64. Initialize Step. This method is called once at the beginning of the step
  65. :return:
  66. '''
  67. # set target tep
  68. self.s = False
  69. self.set_target_temp(self.temp, self.kettle)
  70. def execute(self):
  71. '''
  72. This method is execute in an interval
  73. :return:
  74. '''
  75. # Check if Target Temp is reached
  76. if self.get_kettle_temp(self.kettle) >= float(self.temp) and self.s is False:
  77. self.s = True
  78. self.notify("Step Temp Reached!", "Please press the next button to continue", timeout=None)
  79. @cbpi.step
  80. class ChilStep(StepBase):
  81. timer = Property.Number("Timer in Minutes", configurable=True, default_value=0, description="Timer is started immediately")
  82. @cbpi.action("Stat Timer")
  83. def start(self):
  84. if self.is_timer_finished() is None:
  85. self.start_timer(int(self.timer) * 60)
  86. def reset(self):
  87. self.stop_timer()
  88. def finish(self):
  89. pass
  90. def execute(self):
  91. if self.is_timer_finished() is None:
  92. self.start_timer(int(self.timer) * 60)
  93. if self.is_timer_finished() == True:
  94. self.next()
  95. @cbpi.step
  96. class PumpStep(StepBase):
  97. pump = StepProperty.Actor("Pump", description="Pump actor gets toogled")
  98. timer = Property.Number("Timer in Minutes", configurable=True, default_value=0, description="Timer is started immediately")
  99. @cbpi.action("Stat Timer")
  100. def start(self):
  101. if self.is_timer_finished() is None:
  102. self.start_timer(int(self.timer) * 60)
  103. def reset(self):
  104. self.stop_timer()
  105. def finish(self):
  106. self.actor_off(int(self.pump))
  107. def init(self):
  108. self.actor_on(int(self.pump))
  109. def execute(self):
  110. if self.is_timer_finished() is None:
  111. self.start_timer(int(self.timer) * 60)
  112. if self.is_timer_finished() == True:
  113. self.next()
  114. @cbpi.step
  115. class BoilStep(StepBase):
  116. '''
  117. Just put the decorator @cbpi.step on top of a method
  118. '''
  119. # Properties
  120. temp = Property.Number("Temperature", configurable=True, default_value=100, description="Target temperature for boiling")
  121. kettle = StepProperty.Kettle("Kettle", description="Kettle in which the boiling step takes place")
  122. timer = Property.Number("Timer in Minutes", configurable=True, default_value=90, description="Timer is started when target temperature is reached")
  123. hop_1 = Property.Number("Hop 1 Addition", configurable=True, description="Fist Hop alert")
  124. hop_1_added = Property.Number("",default_value=None)
  125. hop_2 = Property.Number("Hop 2 Addition", configurable=True, description="Second Hop alert")
  126. hop_2_added = Property.Number("", default_value=None)
  127. hop_3 = Property.Number("Hop 3 Addition", configurable=True)
  128. hop_3_added = Property.Number("", default_value=None, description="Third Hop alert")
  129. hop_4 = Property.Number("Hop 4 Addition", configurable=True)
  130. hop_4_added = Property.Number("", default_value=None, description="Fourth Hop alert")
  131. hop_5 = Property.Number("Hop 5 Addition", configurable=True)
  132. hop_5_added = Property.Number("", default_value=None, description="Fifth Hop alert")
  133. fining = Property.Number("Fining Addition", configurable=True, default_value=15)
  134. fining_added = Property.Number("",default_value=None, description="Fining Agent Alert")
  135. def init(self):
  136. '''
  137. Initialize Step. This method is called once at the beginning of the step
  138. :return:
  139. '''
  140. # set target tep
  141. self.set_target_temp(self.temp, self.kettle)
  142. @cbpi.action("Start Timer Now")
  143. def start(self):
  144. '''
  145. Custom Action which can be execute form the brewing dashboard.
  146. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface
  147. :return:
  148. '''
  149. if self.is_timer_finished() is None:
  150. self.start_timer(int(self.timer) * 60)
  151. def reset(self):
  152. self.stop_timer()
  153. self.set_target_temp(self.temp, self.kettle)
  154. def finish(self):
  155. self.set_target_temp(0, self.kettle)
  156. def check_hop_timer(self, number, value):
  157. if self.__getattribute__("hop_%s_added" % number) is not True and (int(value) * 60) == (
  158. self.timer_end - int(time.time())):
  159. self.__setattr__("hop_%s_added" % number, True)
  160. self.notify("Hop Alert", "Please add Hop %s" % number, timeout=None)
  161. def check_fining_timer(self, value):
  162. if self.__getattribute__("fining_added") is not True and (int(value) * 60) == (
  163. self.timer_end - int(time.time())):
  164. self.__setattr__("fining_added", True)
  165. self.notify("Fining Alert", "Please add fining agent", timeout=None)
  166. def execute(self):
  167. '''
  168. This method is execute in an interval
  169. :return:
  170. '''
  171. # Check if Target Temp is reached
  172. if self.get_kettle_temp(self.kettle) >= float(self.temp):
  173. # Check if Timer is Running
  174. if self.is_timer_finished() is None:
  175. self.notify("Boil Temp Reached", "Starting the boil timer")
  176. self.start_timer(int(self.timer) * 60)
  177. else:
  178. self.check_hop_timer(1, self.hop_1)
  179. self.check_hop_timer(2, self.hop_2)
  180. self.check_hop_timer(3, self.hop_3)
  181. self.check_hop_timer(4, self.hop_4)
  182. self.check_hop_timer(5, self.hop_5)
  183. self.check_fining_timer(self.fining)
  184. # Check if timer finished and go to next step
  185. if self.is_timer_finished() == True:
  186. self.notify("Boil Step Completed!", "Starting the next step", timeout=None)
  187. self.next()