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

232 行
7.8KB

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