25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
6.9KB

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