Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

230 рядки
7.6KB

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