diff --git a/octoprint_psucontrol/__init__.py b/octoprint_psucontrol/__init__.py index 7c28c7f..ae99a27 100644 --- a/octoprint_psucontrol/__init__.py +++ b/octoprint_psucontrol/__init__.py @@ -44,6 +44,7 @@ def __init__(self): self._idleIgnoreCommandsArray = [] self.idleTimeoutWaitTemp = 0 self.enableSensing = False + self.disconnectOnPowerOff = False self.senseGPIOPin = 0 self.isPSUOn = False self._noSensing_isPSUOn = False @@ -84,6 +85,9 @@ def on_settings_initialized(self): self.enableSensing = self._settings.get_boolean(["enableSensing"]) self._logger.debug("enableSensing: %s" % self.enableSensing) + self.disconnectOnPowerOff = self._settings.get_boolean(["disconnectOnPowerOff"]) + self._logger.debug("disconnectOnPowerOff: %s" % self.disconnectOnPowerOff) + self.senseGPIOPin = self._settings.get_int(["senseGPIOPin"]) self._logger.debug("senseGPIOPin: %s" % self.senseGPIOPin) @@ -350,6 +354,9 @@ def turn_psu_off(self): except (RuntimeError, ValueError) as e: self._logger.error(e) + if self.disconnectOnPowerOff: + self._printer.disconnect() + if not self.enableSensing: self._noSensing_isPSUOn = False @@ -383,6 +390,7 @@ def get_settings_defaults(self): offSysCommand = '', postOnDelay = 0.0, enableSensing = False, + disconnectOnPowerOff = False, senseGPIOPin = 0, autoOn = False, autoOnTriggerGCodeCommands = "G0,G1,G2,G3,G10,G11,G28,G29,G32,M104,M109,M140,M190", @@ -412,6 +420,7 @@ def on_settings_save(self, data): self.offSysCommand = self._settings.get(["offSysCommand"]) self.postOnDelay = self._settings.get_float(["postOnDelay"]) self.enableSensing = self._settings.get_boolean(["enableSensing"]) + self.disconnectOnPowerOff = self._settings.get_boolean(["disconnectOnPowerOff"]) self.senseGPIOPin = self._settings.get_int(["senseGPIOPin"]) self.autoOn = self._settings.get_boolean(["autoOn"]) self.autoOnTriggerGCodeCommands = self._settings.get(["autoOnTriggerGCodeCommands"]) diff --git a/octoprint_psucontrol/templates/psucontrol_settings.jinja2 b/octoprint_psucontrol/templates/psucontrol_settings.jinja2 index 74075f7..b34ef7b 100644 --- a/octoprint_psucontrol/templates/psucontrol_settings.jinja2 +++ b/octoprint_psucontrol/templates/psucontrol_settings.jinja2 @@ -150,5 +150,11 @@ - +