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.

43 line
1.0KB

  1. from modules import cbpi
  2. from modules.core.controller import KettleController
  3. from modules.core.props import Property
  4. @cbpi.controller
  5. class Hysteresis(KettleController):
  6. # Custom Properties
  7. on = Property.Number("Offset On", True, 0)
  8. off = Property.Number("Offset Off", True, 0)
  9. def stop(self):
  10. '''
  11. Invoked when the automatic is stopped.
  12. Normally you switch off the actors and clean up everything
  13. :return: None
  14. '''
  15. super(KettleController, self).stop()
  16. self.heater_off()
  17. def run(self):
  18. '''
  19. Each controller is exectuted in its own thread. The run method is the entry point
  20. :return:
  21. '''
  22. while self.is_running():
  23. self.actor_power(50)
  24. if self.get_temp() < self.get_target_temp() - int(self.on):
  25. self.heater_on(100)
  26. elif self.get_temp() >= self.get_target_temp() - int(self.off):
  27. self.heater_off()
  28. else:
  29. self.heater_off()
  30. self.sleep(1)