Skip to content

Commit

Permalink
Option to disconnect on power off. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
kantlivelong committed Apr 9, 2017
1 parent d50aeac commit 748c034
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions octoprint_psucontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"])
Expand Down
8 changes: 7 additions & 1 deletion octoprint_psucontrol/templates/psucontrol_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,11 @@
</div>
</div>
<!-- /ko -->

<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.psucontrol.disconnectOnPowerOff"> Disconnect on power off.
</label>
</div>
</div>
</form>

0 comments on commit 748c034

Please sign in to comment.