Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

230 строки
7.5KB

  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="Fives 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 isinstance(value, int) and \
  156. self.__getattribute__("hop_%s_added" % number) is not True and time.time() > (
  157. self.timer_end - (int(self.timer) * 60 - int(value) * 60)):
  158. self.__setattr__("hop_%s_added" % number, True)
  159. self.notify("Hop Alert", "Please add Hop %s" % number, timeout=None)
  160. def execute(self):
  161. '''
  162. This method is execute in an interval
  163. :return:
  164. '''
  165. # Check if Target Temp is reached
  166. if self.get_kettle_temp(self.kettle) >= float(self.temp):
  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. self.check_hop_timer(4, self.hop_4)
  175. self.check_hop_timer(5, self.hop_5)
  176. # Check if timer finished and go to next step
  177. if self.is_timer_finished() == True:
  178. self.notify("Boil Step Completed!", "Starting the next step", timeout=None)
  179. self.next()