Skip to content
Open
78 changes: 78 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--
READ THE FOLLOWING FIRST:

If not already done, please read the Wiki: https://github.com/kantlivelong/OctoPrint-PSUControl/wiki

This is a bug and feature tracker, please only use it to report bugs
or request features within OctoPrint-PSUControl.

Do not seek support here ("I need help with ...", "I have a
question ..."), that belongs on the community forum at
discourse.octoprint.org, NOT here.

Mark requests with a "[Request]" prefix in the title please. For bug
reports fully fill out the bug reporting template.

When reporting a bug do NOT delete ANY lines from the template.

Make sure any bug you want to report is still present with the CURRENT
OctoPrint-PSUControl version.

Thanks!
-->

#### What were you doing?

<!--
Please be as specific as possible here. The maintainers will need to
reproduce your issue in order to fix it and that is not possible if they
don't know what you did to get it to happen in the first place.

Ideally provide exact steps to follow in order to reproduce your problem:
-->

1. ...
2. ...
3. ...

<!--
If you encountered a problem with specific files of any sorts, make sure
to also include a link to a file with which to reproduce the problem.
-->

#### What did you expect to happen?

#### What happened instead?

#### Version of OctoPrint-PSUControl

<!--
Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.
-->

#### Operating System running OctoPrint

<!--
OctoPi, Linux, Windows, MacOS, something else? With version please.
OctoPi's version can be found in /etc/octopi_version or in the lower left
corner of the web interface.
-->

#### Printer model & used firmware incl. version

<!--
If applicable, always include if unsure.
-->


#### Link to octoprint.log with octoprnt.plugins.psucontrol set to DEBUG

<!--
On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.
-->

#### Wiring diagram

<!--
If applicable.
-->
17 changes: 15 additions & 2 deletions octoprint_psucontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self):
self.autoConnectBaudrate = ''
self.autoConnectPrinterProfile = ''
self.sensingMethod = ''
self.sensePollingInterval = 0
self.senseGPIOPin = 0
self.invertsenseGPIOPin = False
self.senseGPIOPinPUD = ''
Expand Down Expand Up @@ -189,6 +190,9 @@ def on_settings_initialized(self):
self.sensingMethod = self._settings.get(["sensingMethod"])
self._logger.debug("sensingMethod: %s" % self.sensingMethod)

self.sensePollingInterval = self._settings.get_int(["sensePollingInterval"])
self._logger.debug("sensePollingInterval: %s" % self.sensePollingInterval)

self.senseGPIOPin = self._settings.get_int(["senseGPIOPin"])
self._logger.debug("senseGPIOPin: %s" % self.senseGPIOPin)

Expand Down Expand Up @@ -393,7 +397,7 @@ def _check_psu_state(self):

self._plugin_manager.send_plugin_message(self._identifier, dict(hasGPIO=self._hasGPIO, isPSUOn=self.isPSUOn))

self._check_psu_state_event.wait(5)
self._check_psu_state_event.wait(self.sensePollingInterval)
self._check_psu_state_event.clear()

def _start_idle_timer(self):
Expand Down Expand Up @@ -617,6 +621,9 @@ def get_api_commands(self):
getPSUState=[]
)

def on_api_get(self, request):
return self.on_api_command("getPSUState", [])

def on_api_command(self, command, data):
if not user_permission.can():
return make_response("Insufficient rights", 403)
Expand Down Expand Up @@ -655,6 +662,7 @@ def get_settings_defaults(self):
autoConnectPrinterProfile = '',
sensingMethod = 'INTERNAL',
senseGPIOPin = 0,
sensePollingInterval = 5,
invertsenseGPIOPin = False,
senseGPIOPinPUD = '',
senseSystemCommand = '',
Expand Down Expand Up @@ -698,6 +706,7 @@ def on_settings_save(self, data):
self.autoConnectPrinterProfile = self._settings.get(["autoConnectPrinterProfile"])
self.sensingMethod = self._settings.get(["sensingMethod"])
self.senseGPIOPin = self._settings.get_int(["senseGPIOPin"])
self.sensePollingInterval = self._settings.get_int(["sensePollingInterval"])
self.invertsenseGPIOPin = self._settings.get_boolean(["invertsenseGPIOPin"])
self.senseGPIOPinPUD = self._settings.get(["senseGPIOPinPUD"])
self.senseSystemCommand = self._settings.get(["senseSystemCommand"])
Expand Down Expand Up @@ -734,7 +743,10 @@ def get_settings_version(self):
return 3

def on_settings_migrate(self, target, current=None):
if current is None or current < 2:
if current is None:
current = 0

if current < 2:
# v2 changes names of settings variables to accomidate system commands.
cur_switchingMethod = self._settings.get(["switchingMethod"])
if cur_switchingMethod is not None and cur_switchingMethod == "COMMAND":
Expand Down Expand Up @@ -798,6 +810,7 @@ def get_update_information(self):
)

__plugin_name__ = "PSU Control"
__plugin_pythoncompat__ = ">=2.7,<4"

def __plugin_load__():
global __plugin_implementation__
Expand Down
9 changes: 9 additions & 0 deletions octoprint_psucontrol/templates/psucontrol_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@
</div>
</div>
<!-- /ko -->
<div class="control-group">
<label class="control-label">Polling Interval</label>
<div class="controls">
<div class="input-append">
<input type="number" min="1" max="10" step="1" class="input-mini text-right" data-bind="value: settings.plugins.psucontrol.sensePollingInterval">
<span class="add-on">sec</span>
</div>
</div>
</div>
<br />

<h4>Power On Options</h4>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
plugin_identifier = "psucontrol"
plugin_package = "octoprint_%s" % plugin_identifier
plugin_name = "OctoPrint-PSUControl"
plugin_version = "0.1.8"
plugin_version = "0.1.9"
plugin_description = "Control ATX/AUX power supply."
plugin_author = "Shawn Bruce"
plugin_author_email = "kantlivelong@gmail.com"
Expand Down