Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect on external power on #229

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ All support related questions will be closed.
Feature requests should be made at:
https://feathub.com/kantlivelong/OctoPrint-PSUControl

When reporting a bug do NOT delete ANY lines from the template.
When reporting a bug do NOT delete ANY lines from the template or exclude
any information unless otherwise noted.
Failure to follow this will result in the ticket being closed and locked.

Make sure any bug you want to report is still present with the CURRENT
OctoPrint-PSUControl version.
Expand Down
8 changes: 7 additions & 1 deletion octoprint_psucontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def get_settings_defaults(self):
idleIgnoreCommands = 'M105',
idleTimeoutWaitTemp = 50,
turnOnWhenApiUploadPrint = False,
turnOffWhenError = False
turnOffWhenError = False,
connectOnExternalPowerOn=False
)


Expand Down Expand Up @@ -309,6 +310,11 @@ def _check_psu_state(self):

event = Events.PLUGIN_PSUCONTROL_PSU_STATE_CHANGED
self._event_bus.fire(event, payload=dict(isPSUOn=self.isPSUOn))

if (old_isPSUOn != self.isPSUOn) and self.isPSUOn and self.config['connectOnExternalPowerOn'] and self._printer.is_closed_or_error():
time.sleep(0.1 + self.config['postOnDelay'])
self._printer.connect()
time.sleep(0.1)

if (old_isPSUOn != self.isPSUOn) and self.isPSUOn:
self._start_idle_timer()
Expand Down
7 changes: 7 additions & 0 deletions octoprint_psucontrol/templates/psucontrol_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.psucontrol.connectOnExternalPowerOn"> Connect when powered on externally.
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
Expand Down