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.

96 line
2.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)
  13. kettle = StepProperty.Kettle("Kettle")
  14. timer = Property.Number("Timer in Minutes", configurable=True)
  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) >= int(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)
  56. kettle = StepProperty.Kettle("Kettle")
  57. s = False
  58. def init(self):
  59. '''
  60. Initialize Step. This method is called once at the beginning of the step
  61. :return:
  62. '''
  63. # set target tep
  64. self.s = False
  65. self.set_target_temp(self.temp, self.kettle)
  66. def execute(self):
  67. '''
  68. This method is execute in an interval
  69. :return:
  70. '''
  71. # Check if Target Temp is reached
  72. if self.get_kettle_temp(self.kettle) >= int(self.temp) and self.s is False:
  73. self.s = True
  74. self.notify("Step Temp Reached!", "Please press the next button to continue", timeout=None)