Skip to content

Commit

Permalink
0.9.22 (#185)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jneilliii authored Jun 19, 2020
1 parent fbb327d commit 6af433b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Check out my other plugins [here](https://plugins.octoprint.org/by_author/#jneil
### Sponsors
- Andreas Lindermayr
- [@Mearman](https://github.com/Mearman)
- [@TxBillbr](https://github.com/TxBillbr)
- Gerald Dachs

### Support My Efforts
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.
Expand Down
31 changes: 16 additions & 15 deletions octoprint_tplinksmartplug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,21 +604,22 @@ def on_event(self, event, payload):
self._timelapse_active = False
# File Uploaded Event
if event == Events.UPLOAD and self._settings.getBoolean(["event_on_upload_monitoring"]):
self._tplinksmartplug_logger.debug("File uploaded: %s. Turning enabled plugs on." % payload.get("name", ""))
self._tplinksmartplug_logger.debug(payload)
for plug in self._settings.get(['arrSmartplugs']):
self._tplinksmartplug_logger.debug(plug)
if plug["event_on_upload"] == True and not self._printer.is_ready():
self._tplinksmartplug_logger.debug("powering on %s due to %s event." % (plug["ip"], event))
response = self.turn_on(plug["ip"])
if response["currentState"] == "on":
self._tplinksmartplug_logger.debug("power on successful for %s attempting connection in %s seconds" % (plug["ip"], plug.get("autoConnectDelay","0")))
self._plugin_manager.send_plugin_message(self._identifier, response)
if payload.get("path", False) != False and payload.get("target") == "local":
time.sleep(int(plug.get("autoConnectDelay","0"))+1)
if self._printer.is_ready() != False:
self._tplinksmartplug_logger.debug("printer connected starting print of %s" % (payload.get("path", "")))
self._printer.select_file(payload.get("path"), False, printAfterSelect=True)
if payload.get("print", False) != False: # implemnted in OctoPrint version 1.4.1
self._tplinksmartplug_logger.debug("File uploaded: %s. Turning enabled plugs on." % payload.get("name", ""))
self._tplinksmartplug_logger.debug(payload)
for plug in self._settings.get(['arrSmartplugs']):
self._tplinksmartplug_logger.debug(plug)
if plug["event_on_upload"] == True and not self._printer.is_ready():
self._tplinksmartplug_logger.debug("powering on %s due to %s event." % (plug["ip"], event))
response = self.turn_on(plug["ip"])
if response["currentState"] == "on":
self._tplinksmartplug_logger.debug("power on successful for %s attempting connection in %s seconds" % (plug["ip"], plug.get("autoConnectDelay","0")))
self._plugin_manager.send_plugin_message(self._identifier, response)
if payload.get("path", False) != False and payload.get("target") == "local":
time.sleep(int(plug.get("autoConnectDelay","0"))+1)
if self._printer.is_ready() != False:
self._tplinksmartplug_logger.debug("printer connected starting print of %s" % (payload.get("path", "")))
self._printer.select_file(payload.get("path"), False, printAfterSelect=True)


if event in [Events.FILE_ADDED, Events.POWER_ON, Events.POWER_OFF, Events.UPLOAD, Events.FILE_SELECTED, Events.PRINT_STARTED, ]:
Expand Down
3 changes: 2 additions & 1 deletion octoprint_tplinksmartplug/static/js/tplinksmartplug.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ $(function() {
'thermal_runaway':ko.observable(false),
'event_on_error':ko.observable(false),
'event_on_disconnect':ko.observable(false),
'automaticShutdownEnabled':ko.observable(false)});
'automaticShutdownEnabled':ko.observable(false),
'event_on_upload':ko.observable(false)});
self.settings.settings.plugins.tplinksmartplug.arrSmartplugs.push(self.selectedPlug());
$("#TPLinkPlugEditor").modal("show");
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-TPLinkSmartplug"

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

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

0 comments on commit 6af433b

Please sign in to comment.