You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

249 line
7.9KB

  1. from modules.core.basetypes import Step
  2. from modules import cbpi
  3. from modules.core.proptypes import Property
  4. import time
  5. @cbpi.addon.step.type("Dummy Step")
  6. class Dummy(Step):
  7. @cbpi.addon.step.action("WOHOO")
  8. def myaction(self):
  9. self.stop_timer()
  10. self.start_timer(10)
  11. text = Property.Text(label="Text", configurable=True, description="WOHOOO")
  12. time = Property.Text(label="Text", configurable=True, description="WOHOOO")
  13. def execute(self):
  14. pass
  15. def reset(self):
  16. self.stop_timer()
  17. # -*- coding: utf-8 -*-
  18. @cbpi.addon.step.type("Dummy Step")
  19. class MashStep(Step):
  20. '''
  21. Just put the decorator @cbpi.step on top of a method
  22. '''
  23. # Properties
  24. temp = Property.Number("Temperature", configurable=True, description="Target Temperature of Mash Step", unit="C")
  25. kettle = Property.Kettle("Kettle", description="Kettle in which the mashing takes place" )
  26. timer = Property.Number("Timer in Minutes", configurable=True, description="Timer is started when the target temperature is reached")
  27. def init(self):
  28. '''
  29. Initialize Step. This method is called once at the beginning of the step
  30. :return:
  31. '''
  32. # set target tep
  33. self.set_target_temp(self.temp, self.kettle)
  34. @cbpi.addon.step.action("Start Timer")
  35. def start(self):
  36. '''
  37. Custom Action which can be execute form the brewing dashboard.
  38. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface
  39. :return:
  40. '''
  41. if self.is_timer_finished() is None:
  42. self.start_timer(int(self.timer) * 60)
  43. def reset(self):
  44. self.stop_timer()
  45. self.set_target_temp(self.temp, self.kettle)
  46. def finish(self):
  47. self.set_target_temp(0, self.kettle)
  48. def execute(self):
  49. '''
  50. This method is execute in an interval
  51. :return:
  52. '''
  53. # Check if Target Temp is reached
  54. if self.get_kettle_temp(self.kettle) >= float(self.temp):
  55. # Check if Timer is Running
  56. if self.is_timer_finished() is None:
  57. self.start_timer(int(self.timer) * 60)
  58. # Check if timer finished and go to next step
  59. if self.is_timer_finished() == True:
  60. self.api.beep()
  61. self.notify("Mash Step Completed!", "Starting the next step", timeout=None)
  62. self.next()
  63. @cbpi.addon.step.type("MashInStep")
  64. class MashInStep(Step):
  65. '''
  66. Just put the decorator @cbpi.step on top of a method
  67. '''
  68. # Properties
  69. temp = Property.Number("Temperature", configurable=True, description="Target Temperature of Mash Step")
  70. kettle = Property.Kettle("Kettle", description="Kettle in which the mashing takes place")
  71. s = False
  72. def init(self):
  73. '''
  74. Initialize Step. This method is called once at the beginning of the step
  75. :return:
  76. '''
  77. # set target tep
  78. self.s = False
  79. self.set_target_temp(self.temp, self.kettle)
  80. def execute(self):
  81. '''
  82. This method is execute in an interval
  83. :return:
  84. '''
  85. # Check if Target Temp is reached
  86. if self.get_kettle_temp(self.kettle) >= float(self.temp) and self.s is False:
  87. self.s = True
  88. self.notify("Step Temp Reached!", "Please press the next button to continue", timeout=None)
  89. @cbpi.addon.step.type("MashInStep")
  90. class ChilStep(Step):
  91. timer = Property.Number("Timer in Minutes", configurable=True, default_value=0, description="Timer is started immediately")
  92. @cbpi.addon.step.action("Start Timer")
  93. def start(self):
  94. if self.is_timer_finished() is None:
  95. self.start_timer(int(self.timer) * 60)
  96. def reset(self):
  97. self.stop_timer()
  98. def finish(self):
  99. pass
  100. def execute(self):
  101. if self.is_timer_finished() is None:
  102. self.start_timer(int(self.timer) * 60)
  103. if self.is_timer_finished() == True:
  104. self.next()
  105. @cbpi.addon.step.type("MashInStep")
  106. class PumpStep(Step):
  107. pump = Property.Actor("Pump", description="Pump actor gets toogled")
  108. timer = Property.Number("Timer in Minutes", configurable=True, default_value=0, description="Timer is started immediately")
  109. @cbpi.addon.step.action("Start Timer")
  110. def start(self):
  111. if self.is_timer_finished() is None:
  112. self.start_timer(int(self.timer) * 60)
  113. def reset(self):
  114. self.stop_timer()
  115. def finish(self):
  116. self.actor_off(int(self.pump))
  117. def init(self):
  118. self.actor_on(int(self.pump))
  119. def execute(self):
  120. if self.is_timer_finished() is None:
  121. self.start_timer(int(self.timer) * 60)
  122. if self.is_timer_finished() == True:
  123. self.next()
  124. @cbpi.addon.step.type("MashInStep")
  125. class BoilStep(Step):
  126. '''
  127. Just put the decorator @cbpi.step on top of a method
  128. '''
  129. # Properties
  130. temp = Property.Number("Temperature", configurable=True, default_value=100, description="Target temperature for boiling")
  131. kettle = Property.Kettle("Kettle", description="Kettle in which the boiling step takes place")
  132. timer = Property.Number("Timer in Minutes", configurable=True, default_value=90, description="Timer is started when target temperature is reached")
  133. hop_1 = Property.Number("Hop 1 Addition", configurable=True, description="Fist Hop alert")
  134. hop_1_added = Property.Number("",default_value=None)
  135. hop_2 = Property.Number("Hop 2 Addition", configurable=True, description="Second Hop alert")
  136. hop_2_added = Property.Number("", default_value=None)
  137. hop_3 = Property.Number("Hop 3 Addition", configurable=True)
  138. hop_3_added = Property.Number("", default_value=None, description="Third Hop alert")
  139. hop_4 = Property.Number("Hop 4 Addition", configurable=True)
  140. hop_4_added = Property.Number("", default_value=None, description="Fourth Hop alert")
  141. hop_5 = Property.Number("Hop 5 Addition", configurable=True)
  142. hop_5_added = Property.Number("", default_value=None, description="Fives Hop alert")
  143. def init(self):
  144. '''
  145. Initialize Step. This method is called once at the beginning of the step
  146. :return:
  147. '''
  148. # set target tep
  149. self.set_target_temp(self.temp, self.kettle)
  150. @cbpi.addon.step.action("Start Timer")
  151. def start(self):
  152. '''
  153. Custom Action which can be execute form the brewing dashboard.
  154. All method with decorator @cbpi.action("YOUR CUSTOM NAME") will be available in the user interface
  155. :return:
  156. '''
  157. if self.is_timer_finished() is None:
  158. self.start_timer(int(self.timer) * 60)
  159. def reset(self):
  160. self.stop_timer()
  161. self.set_target_temp(self.temp, self.kettle)
  162. def finish(self):
  163. self.set_target_temp(0, self.kettle)
  164. def check_hop_timer(self, number, value):
  165. if self.__getattribute__("hop_%s_added" % number) is not True and time.time() > (
  166. self.timer_end - (int(self.timer) * 60 - int(value) * 60)):
  167. self.__setattr__("hop_%s_added" % number, True)
  168. self.notify("Hop Alert", "Please add Hop %s" % number, timeout=None)
  169. def execute(self):
  170. '''
  171. This method is execute in an interval
  172. :return:
  173. '''
  174. # Check if Target Temp is reached
  175. if self.get_kettle_temp(self.kettle) >= float(self.temp):
  176. # Check if Timer is Running
  177. if self.is_timer_finished() is None:
  178. self.start_timer(int(self.timer) * 60)
  179. else:
  180. self.check_hop_timer(1, self.hop_1)
  181. self.check_hop_timer(2, self.hop_2)
  182. self.check_hop_timer(3, self.hop_3)
  183. self.check_hop_timer(4, self.hop_4)
  184. self.check_hop_timer(5, self.hop_5)
  185. # Check if timer finished and go to next step
  186. if self.is_timer_finished() == True:
  187. self.notify("Boil Step Completed!", "Starting the next step", timeout=None)
  188. self.next()