Skip to content

Commit 6af433b

Browse files
authored
0.9.22 (#185)
* enhance upload event monitoring to only process when auto print is enabled, requires OctoPrint version 1.4.1. * fix add plug issue #184 * update sponsors
1 parent fbb327d commit 6af433b

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Check out my other plugins [here](https://plugins.octoprint.org/by_author/#jneil
6363
### Sponsors
6464
- Andreas Lindermayr
6565
- [@Mearman](https://github.com/Mearman)
66+
- [@TxBillbr](https://github.com/TxBillbr)
67+
- Gerald Dachs
6668

6769
### Support My Efforts
6870
I, jneilliii, programmed this plugin for fun and do my best effort to support those that have issues with it, please return the favor and leave me a tip or become a Patron if you find this plugin helpful and want me to continue future development.

octoprint_tplinksmartplug/__init__.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -604,21 +604,22 @@ def on_event(self, event, payload):
604604
self._timelapse_active = False
605605
# File Uploaded Event
606606
if event == Events.UPLOAD and self._settings.getBoolean(["event_on_upload_monitoring"]):
607-
self._tplinksmartplug_logger.debug("File uploaded: %s. Turning enabled plugs on." % payload.get("name", ""))
608-
self._tplinksmartplug_logger.debug(payload)
609-
for plug in self._settings.get(['arrSmartplugs']):
610-
self._tplinksmartplug_logger.debug(plug)
611-
if plug["event_on_upload"] == True and not self._printer.is_ready():
612-
self._tplinksmartplug_logger.debug("powering on %s due to %s event." % (plug["ip"], event))
613-
response = self.turn_on(plug["ip"])
614-
if response["currentState"] == "on":
615-
self._tplinksmartplug_logger.debug("power on successful for %s attempting connection in %s seconds" % (plug["ip"], plug.get("autoConnectDelay","0")))
616-
self._plugin_manager.send_plugin_message(self._identifier, response)
617-
if payload.get("path", False) != False and payload.get("target") == "local":
618-
time.sleep(int(plug.get("autoConnectDelay","0"))+1)
619-
if self._printer.is_ready() != False:
620-
self._tplinksmartplug_logger.debug("printer connected starting print of %s" % (payload.get("path", "")))
621-
self._printer.select_file(payload.get("path"), False, printAfterSelect=True)
607+
if payload.get("print", False) != False: # implemnted in OctoPrint version 1.4.1
608+
self._tplinksmartplug_logger.debug("File uploaded: %s. Turning enabled plugs on." % payload.get("name", ""))
609+
self._tplinksmartplug_logger.debug(payload)
610+
for plug in self._settings.get(['arrSmartplugs']):
611+
self._tplinksmartplug_logger.debug(plug)
612+
if plug["event_on_upload"] == True and not self._printer.is_ready():
613+
self._tplinksmartplug_logger.debug("powering on %s due to %s event." % (plug["ip"], event))
614+
response = self.turn_on(plug["ip"])
615+
if response["currentState"] == "on":
616+
self._tplinksmartplug_logger.debug("power on successful for %s attempting connection in %s seconds" % (plug["ip"], plug.get("autoConnectDelay","0")))
617+
self._plugin_manager.send_plugin_message(self._identifier, response)
618+
if payload.get("path", False) != False and payload.get("target") == "local":
619+
time.sleep(int(plug.get("autoConnectDelay","0"))+1)
620+
if self._printer.is_ready() != False:
621+
self._tplinksmartplug_logger.debug("printer connected starting print of %s" % (payload.get("path", "")))
622+
self._printer.select_file(payload.get("path"), False, printAfterSelect=True)
622623

623624

624625
if event in [Events.FILE_ADDED, Events.POWER_ON, Events.POWER_OFF, Events.UPLOAD, Events.FILE_SELECTED, Events.PRINT_STARTED, ]:

octoprint_tplinksmartplug/static/js/tplinksmartplug.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ $(function() {
272272
'thermal_runaway':ko.observable(false),
273273
'event_on_error':ko.observable(false),
274274
'event_on_disconnect':ko.observable(false),
275-
'automaticShutdownEnabled':ko.observable(false)});
275+
'automaticShutdownEnabled':ko.observable(false),
276+
'event_on_upload':ko.observable(false)});
276277
self.settings.settings.plugins.tplinksmartplug.arrSmartplugs.push(self.selectedPlug());
277278
$("#TPLinkPlugEditor").modal("show");
278279
}

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
plugin_name = "OctoPrint-TPLinkSmartplug"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "0.9.21"
17+
plugin_version = "0.9.22"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module

0 commit comments

Comments
 (0)