Skip to content

Commit

Permalink
0.9.26 (#224)
Browse files Browse the repository at this point in the history
* add uptime check to verify system uptime is not below our timeout threshold
* fix issues related to uptime comparison on startup
* fix powering on during startup when doing a cold boot
  • Loading branch information
jneilliii authored Nov 21, 2020
1 parent 485ff1d commit 1cecbda
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 219 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ Once installed go into settings and enter the ip address for your TP-Link Smartp
- **Run System Command Before Off**
- When checked will run system command configured in **System Command Off** setting after a delay in seconds configured in **System Command Off Delay**.

## Most recent changelog

**[0.9.26](https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/releases/tag/0.9.26)** (11/20/2020)

* add uptime check to verify system uptime is not below our timeout threshold
* fix issues related to uptime comparison on startup
* fix powering on during startup when doing a cold boot


### [All releases](https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/releases)

## Get Help

If you experience issues with this plugin or need assistance please use the issue tracker by clicking issues above.
Expand Down
216 changes: 0 additions & 216 deletions changelog.md

This file was deleted.

18 changes: 17 additions & 1 deletion octoprint_tplinksmartplug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import time
import sqlite3
import decimal
from uptime import uptime
from datetime import datetime
from struct import unpack
from builtins import bytes
Expand Down Expand Up @@ -142,7 +143,16 @@ def on_after_startup(self):
self._tplinksmartplug_logger.debug("idleIgnoreCommands: %s" % self.idleIgnoreCommands)
self.idleTimeoutWaitTemp = self._settings.get_int(["idleTimeoutWaitTemp"])
self._tplinksmartplug_logger.debug("idleTimeoutWaitTemp: %s" % self.idleTimeoutWaitTemp)

if self._settings.get_boolean(["event_on_startup_monitoring"]) is True:
self._tplinksmartplug_logger.debug("powering on due to startup.")
for plug in self._settings.get(['arrSmartplugs']):
if plug["event_on_startup"] is True:
self._tplinksmartplug_logger.debug("powering on %s due to startup." % (plug["ip"]))
response = self.turn_on(plug["ip"])
if response.get("currentState", False) == "on":
self._plugin_manager.send_plugin_message(self._identifier, response)
else:
self._tplinksmartplug_logger.debug("powering on %s during startup failed." % (plug["ip"]))
self._reset_idle_timer()

##~~ SettingsPlugin mixin
Expand Down Expand Up @@ -731,6 +741,12 @@ def _idle_poweroff(self):
if self._printer.is_printing() or self._printer.is_paused():
return

if (uptime()/60) <= (self._settings.get_int(["idleTimeout"])):
self._tplinksmartplug_logger.debug("Just booted so wait for time sync.")
self._tplinksmartplug_logger.debug("uptime: {}, comparison: {}".format((uptime()/60), (self._settings.get_int(["idleTimeout"]))))
self._reset_idle_timer()
return

self._tplinksmartplug_logger.debug(
"Idle timeout reached after %s minute(s). Turning heaters off prior to powering off plugs." % self.idleTimeout)
if self._wait_for_heaters():
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
###

.
uptime
4 changes: 2 additions & 2 deletions 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.25"
plugin_version = "0.9.26"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand All @@ -33,7 +33,7 @@
plugin_license = "AGPLv3"

# Any additional requirements besides OctoPrint should be listed here
plugin_requires = []
plugin_requires = ["uptime"]

### --------------------------------------------------------------------------------------------------------------------
### More advanced options that you usually shouldn't have to touch follow after this point
Expand Down

0 comments on commit 1cecbda

Please sign in to comment.